Hello How can restart iis on a remote machine? I know the ip address and admin user's user name and password information.
A:
How remote is remote? You could just execute Shutdown.exe from your c# code? If that's not possible (firewalls etc) then the next best would probably be putting a service on there that you could call remotely (and securely!) that shuts the machine down.
Steven Robbins
2009-04-01 07:46:33
A:
You could use the "sc" command in order to control the iis-service on the remote machine.
sc \\RemoteServer stop [iis-service-name]
Use
sc help
in order to get a list of possible arguments.
Also take a look at a microsoft kb-article on your subject.
A:
You could use sc, as Thomas Franke suggested:
sc \\RemoteServer stop iisadmin
sc \\RemoteServer start w3svc
or SysInternals' psexec. The PsTools suite is useful for these scenarios.
psexec \\RemoteServer iisreset
George V. Reilly
2009-04-01 08:13:17
A:
ok thank you my code is like below but it does not work :( can you help me
System.Security.SecureString pwd = new System.Security.SecureString();
pwd.AppendChar('p');
pwd.AppendChar('a');
pwd.AppendChar('s');
pwd.AppendChar('s');
pwd.AppendChar('1');
pwd.AppendChar('2');
pwd.AppendChar('3');
string computerName = "WORKPC1201";
string domain = "EXTRAWORKDOMAIN";
Process myProcess = new Process();
//ProcessStartInfo remoteAdmin =
// new ProcessStartInfo("psexec.exe", domain + "\\\\" + computerName + " -i -c \"ie.bat\"");
ProcessStartInfo remoteAdmin =
new ProcessStartInfo("c:\\Windows\\System32\\sc.exe", "\\\\" + computerName + " stop iisadmin");
remoteAdmin.UserName = "adminuser";
remoteAdmin.Password = pwd;
remoteAdmin.Domain = domain;
myProcess.StartInfo = remoteAdmin;
myProcess.StartInfo.UseShellExecute = false;
myProcess.Start();
myProcess.WaitForExit();
How does it not work? Are there error codes? Have you tried running the command manually to make sure there isn't something else wrong?
Matthew Talbert
2009-09-08 20:34:28