Reputation: 121
My PC is in Domain A and a remote server in Domain B, I want to restart a service on server from my PC using c# or any other language or script.
Notes:
Upvotes: 5
Views: 6637
Reputation: 86718
Can you use a batch file? I usually use something like this:
NET USE \\computername\IPC$ /U:domainname\username password
SC \\computername START service
Upvotes: 3
Reputation: 1139
You should first try the sc
command to make sure you're able to start that service remotely using the current permissions and credentials. If that works, take a look at System.ServiceProcess.ServiceController
.
When you say you're an admin on the remote machine, I'm assuming that means you're logging in with different credentials. I don't believe either of those will allow you to use alternate credentials -- i.e., the commands will execute with Domain A privileges and those privileges are most likely insufficient for what you're trying to do.
Upvotes: 3