Solved

vbs script to  run external executable and move file

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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