Start And Stop Windows Service remotely using PSEXEC

105,855

Solution 1

I can't test this right now, but it ought to be:

psexec \\server -u username -p password net start ArgusCommunityWorkerService

and

psexec \\server -u username -p password net stop ArgusCommunityWorkerService

Solution 2

PSService on SysInternals is specifically for remotely controlling services::`

psservice [\\computer [-u username] [-p password]] <command> <options>

where:

query Displays the status of a service.

config Displays the configuration of a service.

setconfig Sets the start type (disabled, auto, demand) of a service.

start Starts a service.

stop Stops a service.

restart Stops and then restarts a service.

pause Pauses a service

cont Resumes a paused service.

depend Lists the services dependent on the one specified.

security Dumps the service's security descriptor.

find Searches the network for the specified service.

\\computer Targets the NT/Win2K system specified.

Include the -u switch with a username and password to login to the remote system if your security credentials do not permit you to obtain performance counter information from the remote system. If you specify the -u option, but not a password with the -p option, PsService will prompt you to enter the password and will not echo it to the screen.

Solution 3

Another alternative to psexec is sc. You can use sc to start or stop services remotely:

sc \\server start ServiceName

sc \\server stop ServiceName

There is no "login" information, so maybe you need to execute

net use \\server password /USER:user

before executing sc command.

One advantage over psexec is that no console window shows in the remote machine.

Share:
105,855
Selwyn
Author by

Selwyn

I am a software developer and work on .NET technologies

Updated on July 09, 2022

Comments

  • Selwyn
    Selwyn almost 2 years

    How to start and and stop a Windows service remotely using PSEXEC? Preferably the syntax to write I tried the cmdlet given below

    psexec \\Server -u Administrator -p Somepassword ServiceName