Solved

vbs script to  run external executable and move file

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Ok I have been working on this for some time having learned and gained certification in XenDesktop 4 along came version 5 which was released last month. Since then I have been working to deploy XenDesktop 5 in a small environment with only 2 virt…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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