llarava
asked on
I need help to translate a really simple batch file to VBS
Hi,
We have a batch file with the following code.
psservice \\servername restart messenger
The batch file is not supported by the scheduler system that we are using and it needs to be moved to vbs.
Can someone help me out to translate this into a VBS?
Thank you.
---------------------
Usage: psservice [\\computer [-u username] [-p password]] <command> <options>
query Displays the status of a service.
config Displays the configuration of a service.
setconfig Sets the start type (disabled, auto, demand) of a service.
start Starts a service.
stop Stops a service.
restart Stops and then restarts a service.
pause Pauses a service
cont Resumes a paused service.
depend Lists the services dependent on the one specified.
security Dumps the service's security descriptor.
find Searches the network for the specified service.
\\computer Targets the NT/Win2K system specified. Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system. If you specify the -u option, but not a password with the -p option, PsService will prompt you to enter the password and will not echo it to the screen.
We have a batch file with the following code.
psservice \\servername restart messenger
The batch file is not supported by the scheduler system that we are using and it needs to be moved to vbs.
Can someone help me out to translate this into a VBS?
Thank you.
---------------------
Usage: psservice [\\computer [-u username] [-p password]] <command> <options>
query Displays the status of a service.
config Displays the configuration of a service.
setconfig Sets the start type (disabled, auto, demand) of a service.
start Starts a service.
stop Stops a service.
restart Stops and then restarts a service.
pause Pauses a service
cont Resumes a paused service.
depend Lists the services dependent on the one specified.
security Dumps the service's security descriptor.
find Searches the network for the specified service.
\\computer Targets the NT/Win2K system specified. Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system. If you specify the -u option, but not a password with the -p option, PsService will prompt you to enter the password and will not echo it to the screen.
You may need to change this...
cmd = "psservice \\" & strcomputer & " restart messenger"
...to include the FULL PATH to psservice.
cmd = "C:\psservice.exe \\" & strcomputer & " restart messenger"
cmd = "psservice \\" & strcomputer & " restart messenger"
...to include the FULL PATH to psservice.
cmd = "C:\psservice.exe \\" & strcomputer & " restart messenger"
Oh...I forgot...
You have to call it like this...
script.vbs "computername"
You have to call it like this...
script.vbs "computername"
ASKER
The servername has to be hardcoded within the script.
set args=wscript.arguments
strcomputer = server1
cmd = "C:\temp\psservice \\" & strcomputer & " restart messenger"
set WshShell = WScript.CreateObject("WScr ipt.Shell" )
wshShell.run cmd
Line2 / Char 13 error
set args=wscript.arguments
strcomputer = server1
cmd = "C:\temp\psservice \\" & strcomputer & " restart messenger"
set WshShell = WScript.CreateObject("WScr
wshShell.run cmd
Line2 / Char 13 error
...just put it in like this.
cmd = "cmd /c C:\temp\psservice \\server1 restart messenger"
cmd = "cmd /c C:\temp\psservice \\server1 restart messenger"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just curious, what scheduler are you using, seems a little odd that it would support VBS scripts, but not BAT or CMD scripts.
~bp
~bp
ASKER
I had the same thought when someone said this to me today...
This is all custom made by one of our vendors that is no longer in business. This is just a patch in order for their custom app to run. We will be replacing this as soon as we are done testing the new business app.
This is all custom made by one of our vendors that is no longer in business. This is just a patch in order for their custom app to run. We will be replacing this as soon as we are done testing the new business app.
set args=wscript.arguments
strcomputer = args(0)
cmd = "psservice \\" & strcomputer & " restart messenger"
set WshShell = WScript.CreateObject("WScr
wshShell.run cmd