Solved

vbs script to  run external executable and move file

Posted on 2006-10-23
3
899 Views
Last Modified: 2012-05-05
Hello,

Would you please help me?

I need batch file that will run on Windows XP PC, but not with command prompt but background.
I have no single experience on vbs but I learned from Experts log that vbs can run in background....

What I need to do....
1) check file *yyyymmdd.txt exist or not, if not, exit  (yyyymmdd is today's date)
2) run external executable (written in C++) to this particular file with passing the file name as valuable.
3) check if directory called "Archive" exists or not, if not, create the directory
4) move the *yyyymmdd.txt into Archive


Would somebody help me on this?
0
Comment
Question by:sleepingluke
  • 2
3 Comments
 
LVL 22

Expert Comment

by:cj_1969
ID: 17787995
Being a vb script you have 2 ways to run this ... cscript or wscript
cscript runs it ina command-line type window and wscript will run it in a windows environment.
BUT from your question, I get the feeling that you want cscript, you just don't want to have to run it manually, you want it to execute and stay running, without being on the desktop ... if so, then you probably want to look at running it as a service.

Check out this page ... it should have all the info you need for this ... http://support.microsoft.com/kb/q137890/
0
 
LVL 22

Accepted Solution

by:
cj_1969 earned 250 total points
ID: 17788221
I think to do what you want, all you need is a batch file and use the schedule command.
If you specify an alternate ID for the job to run under then it will not appear on the desktop, it will run in the background.
Also, since this is a daily file, it doesn't make sense to have something running constantly when it just needds to run once a day.
Try the following and see if this, in addition to the scheduled job, does what you need ...

copy the contents between the lines into a file with a .cmd extenstion and modify the lines that are noted to be customized
-------------------------------------------------
@echo off

REM *** ENVIRONMENT VARIABLES, INITIALIZE VALUES
for /F "tokens=1,2" %%a in ('DATE /T') do SET sysDate=%%b
SET sysMonth=%sysDate:~0,2%
SET sysDay=%sysDate:~3,2%
SET sysYear=%sysDate:~6,4%
SET FileName=%sysYear%%sysMonth%%sysDay%.txt

REM *** Change Source File Directory Reference
SET dirPath=.\
SET DailyFile=%dirPath%%FileName%

REM *** Change Archive Directory Reference
SET ArchiveDirectory=.\Archive\

REM *** Change Executable Application Reference
SET ExecutableApplication="c:\program files\some application\thisApp.exe"


REM *** Check to see if the file exists
if exist %DailyFile% (
  call %ExecutableApplication% %DailyFile%
  mkdir %ArchiveDirectory%
  copy /Y %DailyFile% %ArchiveDirectory%%FileName%
)
-------------------------------------------------
0
 

Author Comment

by:sleepingluke
ID: 17792528
Hi, cj 1969,

Thank you very much, it works very well!!!!!

:-D appreciated!!!

sleepingluke

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now