We help IT Professionals succeed at work.

Batch file to run specific program to stop a service on multiple pcs

1,102 Views
Last Modified: 2010-04-21
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.Shell")
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,

Comment
Watch Question

Lee W, MVPTechnology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
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.
Lee W, MVPTechnology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:

Commented:
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

Author

Commented:
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
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Allright!!!! it pays to read about what I am trying to accomplish!!!!

It saved me a lot of typing!!!!

thanks!!!
Jose

Author

Commented:
THANKS a BUNCH!!!!
Lee W, MVPTechnology and Business Process Advisor
CERTIFIED EXPERT
Most Valuable Expert 2013

Commented:
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.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.