HockeyFan Posted August 16, 2005 Share Posted August 16, 2005 Help! Is there a function to stop a Windows XP Pro service and then start it up again? I've used ProcessClose but after a set time, the process is re-launched. I need to stop a service while I install a program and then start the service up after the install has completed. Link to comment Share on other sites More sharing options...
seandisanti Posted August 16, 2005 Share Posted August 16, 2005 Help! Is there a function to stop a Windows XP Pro service and then start it up again? I've used ProcessClose but after a set time, the process is re-launched. I need to stop a service while I install a program and then start the service up after the install has completed. <{POST_SNAPBACK}>easiest way may be to just BlockInput() then run services.exe, find the one service with arrow presses, then go to properties, and disable/stop the service with controlclick's, then run your install, restart service and set startup to auto/manual and close out of services.exe before unblocking inputs...not the prettiest way to do it, but definitley the least amount of code Link to comment Share on other sites More sharing options...
Josbe Posted August 16, 2005 Share Posted August 16, 2005 Stop a service? Net Stop AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
HockeyFan Posted August 16, 2005 Author Share Posted August 16, 2005 Stop a service? Net Stop<{POST_SNAPBACK}>What is the proper syntax to use with net stop?Thanks for your help! Link to comment Share on other sites More sharing options...
Josbe Posted August 16, 2005 Share Posted August 16, 2005 What is the proper syntax to use with net stop?Thanks for your help!<{POST_SNAPBACK}>Check the link. net stop "service" AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
herewasplato Posted August 16, 2005 Share Posted August 16, 2005 What is the proper syntax to use with net stop?...<{POST_SNAPBACK}>See that little button named "Search"?Search the forum for "net stop" and read some of the posts.I could give you the AutoIt syntax, but there is a bit that you should know about how services are named - especially if the service is not native to the OS.I'll give you one forum link to get you started:http://www.autoitscript.com/forum/index.ph...indpost&p=77261enjoy [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
HockeyFan Posted August 16, 2005 Author Share Posted August 16, 2005 Check the link. net stop "service"<{POST_SNAPBACK}> Pardon my ignorance...I understand the syntax with Net Start...(net stop "service_name")...but how do I use that within the code? Do I use Run? Link to comment Share on other sites More sharing options...
seandisanti Posted August 16, 2005 Share Posted August 16, 2005 Stop a service? Net Stop<{POST_SNAPBACK}>cool! does this only work for the services listed, or could it be used to stop 3rd party services also? Link to comment Share on other sites More sharing options...
sim Posted August 16, 2005 Share Posted August 16, 2005 (edited) this is not best way to stop service net stop not stopping some services like firewall and antivirus but this method works almost for all $oShell=ObjCreate('shell.application') $oShell.Servicestop('messenger', true) regards asimzameer Edited August 16, 2005 by sim Link to comment Share on other sites More sharing options...
herewasplato Posted August 16, 2005 Share Posted August 16, 2005 cool! does this only work for the services listed, or could it be used to stop 3rd party services also?<{POST_SNAPBACK}>...from the MS link that was posted by Josbe:"Net stop can also stop services not provided with Windows XP." [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
seandisanti Posted August 16, 2005 Share Posted August 16, 2005 ...from the MS link that was posted by Josbe:"Net stop can also stop services not provided with Windows XP."<{POST_SNAPBACK}> i was just um... testing you.... Link to comment Share on other sites More sharing options...
Josbe Posted August 16, 2005 Share Posted August 16, 2005 Pardon my ignorance...I understand the syntax with Net Start...(net stop "service_name")...but how do I use that within the code? Do I use Run? <{POST_SNAPBACK}>An example (untested code)._switchService( "messenger", 1 );start the service specified _switchService( "messenger", 0 );stop the service specified Func _switchService( $sService, $state ) If $state = 0 then $sCmd = "stop" Else $sCmd = "start" EndIf RunWait(@comspec & " /c net " & $sCmd & " " & $sService, '', @SW_HIDE) EndFuncof course, the line that you need:$sService = "aServiceName" RunWait(@comspec & " /c net stop " & $sService, '', @SW_HIDE) AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta Link to comment Share on other sites More sharing options...
herewasplato Posted August 16, 2005 Share Posted August 16, 2005 ...net stop not stopping some services...<{POST_SNAPBACK}>The link I gave has a good script by Sven that documents the "Obj method" pretty well... but if net stop works, there is little reason to use the "Obj method"....but if you are making a virus... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
seandisanti Posted August 16, 2005 Share Posted August 16, 2005 The link I gave has a good script by Sven that documents the "Obj method" pretty well... but if net stop works, there is little reason to use the "Obj method"....but if you are making a virus...<{POST_SNAPBACK}>careful, might hurt someone's feelings...plato are bad. you are not to be making fun of me and my attempts to make more secure your windows program. i not hurt your computers, i already invented computer that no need even power, that how nice is my skills. Link to comment Share on other sites More sharing options...
herewasplato Posted August 16, 2005 Share Posted August 16, 2005 i was just um... testing you.... <{POST_SNAPBACK}>I've used net stop to stop "3rd party" services before... I was just glad to see that MS offered that tidbit of info in that online doc (I had not seen that statement before). I was not attempting to convey that you should have noticed every line of that doc at first glance and I should not have made such a terse post..... thanks for your gracious and humorous reply. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted August 16, 2005 Share Posted August 16, 2005 (edited) careful, might hurt someone's feelings...<{POST_SNAPBACK}>moi?okay - this is the first time that I've ever used this: LOLNotice to whom I am careful...Where is Kurt when you need him?edit: sorry to the rest of the forum members - just a series of posts with inside jokes. Hope that HockeyFan got the help needed. Edited August 16, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
seandisanti Posted August 16, 2005 Share Posted August 16, 2005 I've used net stop to stop "3rd party" services before... I was just glad to see that MS offered that tidbit of info in that online doc (I had not seen that statement before). I was not attempting to convey that you should have noticed every line of that doc at first glance and I should not have made such a terse post..... thanks for your gracious and humorous reply.<{POST_SNAPBACK}>no worries man, i work for a collections agency, you'd have to be much meaner to hurt my feelings. and i never take offense to constructive criticism. I only scanned the linked page without actually reading it, and then asked a stupid question. Link to comment Share on other sites More sharing options...
rmorrow Posted August 16, 2005 Share Posted August 16, 2005 If you like the object method, note some other methods you can use that the "net" command doesn't offer:This will start a service: $oShell.ServiceStart('messenger', true) This will stop a service: $oShell.ServiceStop('messenger') This will tell you if the service is running: $oShell.IsServiceRunning('messenger') This will tell you if you have permission to start and stop services: $oShell.CanStartStopService('messenger')In fact, for those who are interested, there are a ton of great objects to use in the shell collection. Start with this link:MSDN: Shell Objects for Scripting and Microsoft Visual Basic Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now