Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
This does not work when I run it on one machine to restart a service on another machine. –  AgentFire Apr 4 '13 at 6:23
    
I have both, simple and power. –  AgentFire Apr 4 '13 at 6:58
    
What error do you get? –  ekaj Apr 4 '13 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 '13 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. –  ekaj Apr 4 '13 at 7:10

You can try something like this:

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

Works from Windows 8 to Server 2012.

share|improve this answer
    
[SC] StartService: OpenService FAILED 5: access denied. –  AgentFire Apr 4 '13 at 6:57
    
How to, at first, logon to the remote machine? –  AgentFire Apr 4 '13 at 12:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.