I am very new to VBS, but thought I could create a simple script that
would be scheduled to run a couple times a day to make an archive of
my webcam video.
I created the script, but it doesn't work sometimes. Here is what it
does: Stop program (dorgem.exe), move webcam video to Archive folder,
start program (dorgem.exe).
It works great, except sometimes dorgem does not close. If I use the /
F option with taskkill the program does not start up properly the next
time. I think the solution would be to have the script verify that
the process "dorgem.exe" halted and then continue with the file move,
and if the program did not halt try again 60 seconds later (It seems
to work after the 2nd or 3rd time if I do this manually from the
command line).
Can anybody give me some clues on how to do this? I cant seem to find
the answer online.
Here is my script...
'This script closes dorgem, moves a file, then opens dorgem.
'
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("taskkill /IM dorgem.exe")
WScript.sleep 2000
Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run ("C:\Windows\system32\cmd.exe")
WScript.sleep 1000
'WshShell.SendKeys "move ""C:\Documents and Settings\doggod\My
Documents\My Videos\vidcap*"""
'WshShell.SendKeys " ""C:\Documents and Settings\doggod\My Documents
\My Videos\Archive\vidcap6pm"""
'WshShell.SendKeys "{ENTER}"
WshShell.SendKeys """C:\PROGRAM FILES\Dorgem\Dorgem.exe"""
WshShell.SendKeys "{ENTER}"
WScript.sleep 400
WshShell.SendKeys "exit"
WshShell.SendKeys "{ENTER}"