Jump to content

Help Stopping a Windows XP Pro Service


Recommended Posts

Help! :whistle:

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. :dance:

Link to comment
Share on other sites

Help!  :whistle:

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.  :dance:

<{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

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=77261

enjoy

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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 by sim
Link to comment
Share on other sites

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

:dance:  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?  :whistle:

<{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)
EndFunc

of course, the line that you need:

$sService = "aServiceName"
RunWait(@comspec & " /c net stop " & $sService, '', @SW_HIDE)
Link to comment
Share on other sites

...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

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

:whistle: i was just um... testing you.... :dance:

<{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

careful, might hurt someone's feelings...

<{POST_SNAPBACK}>

moi?

okay - this is the first time that I've ever used this: LOL

Notice 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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...