Solved

vbs script to  run external executable and move file

Posted on 2006-10-23
3
896 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

19 Experts available now in Live!

Get 1:1 Help Now