1.

Solve : Standardizing Taskkill/Restart Script?

Answer»

This is something I am trying to figure out on my freetime, however it is work related.

What I want to do is have one script complete a set of tasks instead of having to manage multiply scripts ...


VSUSERVER
RBOXSERVER
VENGINE1
VENGINE2 ... etc, usually no more then six

Currently I have a script that runs on VENGINE# that will kill a running task named VENGINE, rename a file and then restarts, it is set to go off at about 4:00am, this same script can ALSO be run manually during BUSINESS hours and if it isn't around 4am it will not rename the file. This script is calling a VBS file that passes the enter key as when the application restarts if it has jobs to process it will prompt the user to re-enable the runs by clicking Yes.  In this environment, we have about 4 VSUSERVER's, an RBOXSERVER for each. and in most case about 6 VENGINE's for each VSUSERVER

What I want to do, I only want to have to manage 4 Scripts by having a script on the VSUSERVER that will kill the VENGINE process, rename the needed file like above, restart the application. By renaming the file, pressing enter shouldn't be needed. I know in dos taskkill will allow you to kill a remote process by its image name, but is there anything to allow you to restart a process remotely?

For those that like reading, below is my current code, if not possible, but you see something I am doing that would be easier a different way, by all means let me know if I can simplify something.

DOS is the primary thing I have been learning, but even my knowledge in that is extremely limit. Learning VB is something I've wanted to do, but finding the time with everything else is extremely time consuming, but please let me know your thoughts, thank you in advance.


In the execution folder I currently have a CHOICE.EXE, and a file called SLEEP.EXE

Code: [Select]Echo Off
Echo.
Echo.

set M=%DATE:~4,2%
set D=%DATE:~7,2%
set Y=%DATE:~10,4%

Set ini=

Set log=C:\vision\batlog
md %log%


Set IVDIR=
Set Root=

Set timetest1=4:30:00.00
Set timetest2=4:38:59.99

Rem ----------------------------------------------------------------------
Rem Samuel Simpson - 12-18-2007 - Issues/Support ... Create Facets Case, thanks
Rem Created to kill the Vengine process and restart it without user interaction
Rem Needs Choice.exe, Sleep.exe as well as passkey.wsf
Rem ----------------------------------------------------------------------

Echo.
Echo.

Rem ----------------------------------------------------------------------
Rem CHECK for VEngine install

if Exist "C:\Vision\Bin\VEngine.exe" Set IVDIR=C:\Vision\Bin\& Set Root=C:& Set log=C:\vision\batlog\restartlog.txt & Set ini=C:\vision\etc\VEstate.ini & MD C:\vision\batlog
rem Echo %IVDIR% & Echo %Root% & Echo %log% & Echo %ini% & Pause
if Exist "D:\Vision\Bin\VEngine.exe" Set IVDIR=D:\Vision\Bin\& Set Root=D:& Set log=D:\vision\batlog\restartlog.txt & Set ini=D:\vision\etc\VEstate.ini & MD D:\vision\batlog
rem Echo %IVDIR% & Echo %Root% & Echo %log% & Echo %ini% & Pause

Rem ----------------------------------------------------------------------

Echo. >>%log%
Echo ----------------------------------------------------------------- >>%log%
Echo %M%/%D%/%Y% %Time% Script Started. >>%log%

Rem Kill VEngine process if running.
Rem Echo Pause before kill for test & Pause
taskkill /F /IM VENGINE.EXE

Rem ----------------------------------------------------------------------
Rem This part of the file will take the VEstate file and rename it with a date stamp,
Rem only if there is not a file already renamed for that day.

:renameloop
if /I %time% GEQ %timetest1% goto next1
goto bypass
:next1
if /I %time% LEQ %timetest2% goto next2
goto bypass
:next2
cls
Echo Sleeping for 10 Seconds, please hold
Sleep 10
if not exist "%ini%.%M%%D%%Y%" rename "%ini%" "VEstate.ini.%M%%D%%Y%" & goto continue1
goto bypass
:continue1
if exist "D:\vision\etc\VEstate.ini.%M%%D%%Y%" Echo    %M%/%D%/%Y% %Time% Renamed VEstate.ini >>%log% & Echo %M%/%D%/%Y% %Time% Renamed VEstate.ini & goto continue2
goto renameloop

:bypass
Echo    %M%/%D%/%Y% %Time% Bypassed renaming VEstate.ini >>%log%
Echo %M%/%D%/%Y% %Time% Bypassed renaming VEstate.ini

Echo.
Echo.

Rem ----------------------------------------------------------------------

:Continue2
Echo.
Echo Please Hold
Title Restarting VEngine

choice /c1 /t:1,02 /n > nul

If Errorlevel 2 Pause & Echo Possible ERROR, Please try manual restart
If ErrorLevel 1 Goto StartVE
Goto End

Rem ----------------------------------------------------------------------
:StartVE
Echo.
cls
%Root%
if Exist %IVDIR%\VEngine.exe Start %IVDIR%\VEngine.exe & Goto Completed
Goto Failed
:Completed

Echo %M%/%D%/%Y% %Time% Restarting Vengine process >>%log%
Title Passing Key Press {Enter}
start passkey.wsf & goto END

Rem ----------------------------------------------------------------------
:End
exit

:Failed
Echo %M%/%D%/%Y% %Time% Restarting Vengine process Failed >>%log%
Start notepad %log% & Goto End
Passkey.wsf
Code: [Select]<package>

   <job id="vbs">

      <script language="VBScript">

         set WshShell = WScript.CreateObject("WScript.Shell")

WScript.Sleep 4000
         
WshShell.AppActivate ("VENGINE")

         WshShell.SendKeys "{Enter}"

      </script>

   </job>
</package>




Discussion

No Comment Found