Jose Rivera-Hernandez
asked on
Batch file to run specific program to stop a service on multiple pcs
I have this third-party service installed which will not be stopped using WMI, services, net stop, and the vendor is saying that it is a security feature and to stop it through the command line using
C:\dlservice.exe -e
This works fine, but what if I need to stop it on more then one machine, I have 300 machines!!! I found this script that says that it can execute this command by opening a shell but is not working on my pc?
set objShell= CreateObject("WScript.Shel l")
strCommand= "dir /s C:\ ""C:\Program Files\DeviceLock\DLService .exe -e"""
objShell.Run strCommand,1,True
Is there something else that I should use to execute this particular command "dlservice.exe -e" to 300 computers using a .txt file? Just to clarify the dlservice.exe file is in the System32 folder so that is why I only type C:\dlservice.exe -e
I also need to restart it after I have confirmed that the service was stopped completely; I want a confirmation also.
thank you,
C:\dlservice.exe -e
This works fine, but what if I need to stop it on more then one machine, I have 300 machines!!! I found this script that says that it can execute this command by opening a shell but is not working on my pc?
set objShell= CreateObject("WScript.Shel
strCommand= "dir /s C:\ ""C:\Program Files\DeviceLock\DLService
objShell.Run strCommand,1,True
Is there something else that I should use to execute this particular command "dlservice.exe -e" to 300 computers using a .txt file? Just to clarify the dlservice.exe file is in the System32 folder so that is why I only type C:\dlservice.exe -e
I also need to restart it after I have confirmed that the service was stopped completely; I want a confirmation also.
thank you,
Download the PSTools from Microsoft (formerly sysinternals.com) and use PSEXEC - that should allow you to execute remote commands. Once downloaded, run PSEXEC /? for usage information.
Download PSEXEC (Part of MS Sysinternals) so that you can execute remotely. http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
Run a command prompt as domain admin (or any user with admin rights on each computer) and use the command line:
psexec \\%1 dlservice.exe -e
%1 is a variable to aid you in scripting. If you save the above command to a .cmd file, you can then execute from the command line as yourfile.cmd mypc and it will run psexec \\mypc dlservice.exe -e. Once you have tested and ensured the command line works as expected, you can create another file with all of your machines names, prefixed by call yourfile.cmd. For example:
CallServiceStop.cmd would contain
Call stopdlservice.cmd MyPC
Call stopdlservice.cmd MyPC1
Call stopdlservice.cmd MyPC2
and so on...
stopdlservice.cmd will simply contain psexec \\%1 dlservice.exe -e
Ensure both of these files you create are in the same folder with PSEXEC
Run a command prompt as domain admin (or any user with admin rights on each computer) and use the command line:
psexec \\%1 dlservice.exe -e
%1 is a variable to aid you in scripting. If you save the above command to a .cmd file, you can then execute from the command line as yourfile.cmd mypc and it will run psexec \\mypc dlservice.exe -e. Once you have tested and ensured the command line works as expected, you can create another file with all of your machines names, prefixed by call yourfile.cmd. For example:
CallServiceStop.cmd would contain
Call stopdlservice.cmd MyPC
Call stopdlservice.cmd MyPC1
Call stopdlservice.cmd MyPC2
and so on...
stopdlservice.cmd will simply contain psexec \\%1 dlservice.exe -e
Ensure both of these files you create are in the same folder with PSEXEC
ASKER
jss11999,
I thought of using psexec as it will run commands remotely, and your solution seems to certainly work, but I also saw this other example:
psexec @vnc.txt net start "vnc server"
where the vnc.txt would contain all the computer names, but again the service that I am trying to stop cannot stop with the net start command. do you have any comments about this?
I'll try yours and see if it works, i am in Germany so right now its almost 11 PM, I'll let you know tomorrow.
thanks,
Jose
I thought of using psexec as it will run commands remotely, and your solution seems to certainly work, but I also saw this other example:
psexec @vnc.txt net start "vnc server"
where the vnc.txt would contain all the computer names, but again the service that I am trying to stop cannot stop with the net start command. do you have any comments about this?
I'll try yours and see if it works, i am in Germany so right now its almost 11 PM, I'll let you know tomorrow.
thanks,
Jose
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Allright!!!! it pays to read about what I am trying to accomplish!!!!
It saved me a lot of typing!!!!
thanks!!!
Jose
It saved me a lot of typing!!!!
thanks!!!
Jose
ASKER
THANKS a BUNCH!!!!
Excuse me... didn't I say all that first... No, I didn't specifically state the "@" thing... but if you read my comment and did what I said to do, you'd have seen it - indeed, I suggested the use of PSEXEC and recommended checking the usage... which would have told you that.