Sign in to follow this  
Followers 0
surfdork

script/function for starting and stopping a service

3 posts in this topic

Hi,

Yes I know this should be simple and I've scoured the forums for an answer.

Does AutoIt have a command that can invoke stopping and starting a service?

Ive tried the following

Run('net start iexplore.exe','',@sw_hide) this failed

run("cmd.exe /c sc stop iexplore.exe", "", @SW_HIDE) this failed

Run(@ComSpec & " /c " & 'stop iexplore.exe', "", @SW_HIDE) this failed

OK so I'm very thick headed, I'm just having a heck of a time figuring this out.

Share this post


Link to post
Share on other sites



This example code is working if run as administrator,

RunWait("net stop ""Windows Update""",@SystemDir)

[size="2"][font="Lucida Sans Unicode"][b][/b][/font][/size]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Just like to point out to you that your using SC STOP wrongly, iexplore.exe is not a service its a process

Here is an example of how SC Stop is used(one I use regually at work):

sc stop wuauserv

This basically stops the Windows Update Service, so if your windows has updated and your getting that nasty nag screen asking you to reboot type this in and you wont need to reboot until you are ready ;)

Run("cmd.exe /c sc stop wuauserv" ,"", @SW_HIDE)

That works, just your version didn't work because you were trying to close a process not trying to stop a service

You should be using one of these:

Your first option is:

TASKKILL /IM iexplore.exe /F

/IM is the image name. A process is an image so follow with the definition of the process.

/F basically forces the program to close, it doesn't ask if you are sure or anything.

Second Option:

TASKKILL /FI "WindowTitle"

Obviously the WindowTitle would be something along the lines of Internet Explorer... but this is

Third Option:

TSKILL iexplore /A

tskill is not as good as taskkill but this one will close all instances of Internet Explorer.

Forth Option:

TSKILL iexplore

This one will close the last used (generally) internet explorer instance, but can go wrong and close the wrong one.

Last Option is:

TASKKILL /PID 1234 /F

If you know the PID number, you can put it inplace of 1234 (this one is useless for your script)

Edited by XxXGoD

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0