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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Task Scheduler

Status
Not open for further replies.

bheisser

MIS
Oct 24, 2003
23
US
Have a 2003 server, a application has to run (in a window) the box is logged on. In order to back up the box I need to shut the app down run the backup, and restart the app as an application with it running in the window. I have a winbatch program that runs as a preschuled task to close the program but when it restarts (wether a batch file or scheduled task )it restarts as a process but not an application (a viewable window) anyone know how i can get it to run in an application window
 
You can do this with vbscript using the sendkeys function.

Record all the steps you would do to execute it manually and then put it into a script.

Here is an example that opens a command prompt and then launches calculator:

Code:
Set WshShell = CreateObject("WScript.Shell")
' zero makes window hidden, one makes it normal, false makes it run without waiting to close the application
WshShell.Run "cmd.exe", 1, false
wscript.sleep 200
'Setting focus to the window you want
WshShell.AppActivate "cmd"
'wait for it......
wscript.sleep 200
WshShell.SendKeys "Start calc.exe"
wscript.sleep 200
WshShell.SendKeys "~"

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top