Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to run .exe file(s)

Status
Not open for further replies.

m0nty005

IS-IT--Management
Apr 24, 2004
27
US
I'm looking for a vb script that at a set time would start running execution files one by one (that sits on Folder X). Once an .exe file finishes running, the script should delete that .exe file!

P.S. If it's possible, can this process be logged to the Event Logs?

Much Appreciated,

M0nty
 
Set objFolder = FSO.GetFolder("c:\exes")

For Each aFile In objFolder.Files
If UCase(Right(aFile.Name,4)) = ".EXE" Then
WshShell.LogEvent 0, "Running " & aFile.Name

WshShell.Run(aFile, 1, True)
'maybe WshShell.Run(aFile.Path & "\" & aFile.Name, 1, True)
WshShell.LogEvent 0, "Deleting " & aFile.Name
aFile.Delete
End If
Next


'yes you can log stuff
 
Thanx Movie Dude!

Just 1 more thing: how would I get the vbscript to run at a specified time (code or system settings)? Let's say I want to set it so that the script would run everyday at 6:00AM.

Getting there... .
 
you would be best off setting up an AT command or using the scheduler service

type AT /? or something like that to get help on AT commands.

the scheduler service has a GUI somewhere in windows 2000 or XP

glad i could help
vonmoyla
 
I really appreciate the help fellas!
Got 1 more thing: How can i set a boolean condition to check whether the .exe file ran successfully or not? What I want to do is Log an event to be Successful (or Failed).

I thought that by just adding another line w/ the "1" flag would do the trick, but instead it logs both (which i don't want):

WshShell.LogEvent 0, "Ran this.exe Success" & aFile.Name
WshShell.LogEvent 1, "Ran this.exe Failed" & aFile.Name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top