1

I got administrative rights on the target machine, all the credentials, fully trusted network without firewall and antivirus software. I got windows 8 on the target machine and windows 7 on calling one.

  • I need to restart a windows service by its name. I have this name.

I got the IP address of that machine. I have the simple shell. I could use the powershell however.

Still I cannot find on the internet the fine shell command to do this. Everything I find says either it is impossble or providing not working piece of code.

Update: Both computers are located ta my home and does not belong to domain. They only share teh same workgroup.

Update:

Just created a powershell script:

$password = convertto-securestring -string 'pwd_string' -asplaintext -force
$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist "AF", $password
$service = gwmi win32_service -computername "AgentFire" -filter "name='Sharedaccess'" -credential $credential
$service.stopservice()
Start-Sleep -s 3
$service.startservice()

gwmi says access denied, though credentials are valid.

3 Answers 3

1

You can try something like this:

sc \\SERVER [start|stop|restart] ServiceName

Works from Windows 8 to Server 2012.

2
  • [SC] StartService: OpenService FAILED 5: access denied.
    – AgentFire
    Apr 4, 2013 at 6:57
  • How to, at first, logon to the remote machine?
    – AgentFire
    Apr 4, 2013 at 12:52
1

The only way I could manage to do this is:

PsExec.exe \\192.168.0.106 -u 123 -p 123 -d shutdown /f /s /t 0
  1. External tool from SysInternals.
  2. User-password combo on the target PC
  3. Shutdown.exe shell command.
0

If I'm wrong, please let me know.

According to this site you should be able to use the net [start/stop] [servicename] command to start or stop a service by its name. If you just need to kill a process, you could just get the PID by using tasklist and taskkill with the appropriate flags.

6
  • This does not work when I run it on one machine to restart a service on another machine.
    – AgentFire
    Apr 4, 2013 at 6:23
  • I have both, simple and power.
    – AgentFire
    Apr 4, 2013 at 6:58
  • What error do you get?
    – cutrightjm
    Apr 4, 2013 at 7:02
  • With net [start/stop] [servicename] there is no error as well as any attempt. The command you provided does not allow to specify the remote machine name. Or I cannot find where this can be specified.
    – AgentFire
    Apr 4, 2013 at 7:09
  • You said you had a shell into the second computer. If you had this you wouldn't need to specify the machine name.
    – cutrightjm
    Apr 4, 2013 at 7:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .