hi friends.
i want to shutdown/restart/logoff the remote system in LAN..
how to do that in c#..
i need coding for that in c#.. i am doing this task in windows application using c#...
its urgent friends.
regards
gopal.s
hi friends.
i want to shutdown/restart/logoff the remote system in LAN..
how to do that in c#..
i need coding for that in c#.. i am doing this task in windows application using c#...
its urgent friends.
regards
gopal.s
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vijay YadavPosted Mar 18, 2011, 8:15 AM
I used your method but on local machine it just show command prompt and nothing else
and remote didn't get shutdown
jayakrishnan MorayurPosted Mar 18, 2011, 6:37 AM
hung cuong nguyenPosted May 27, 2010, 6:02 AM
Thanks
ashaPosted Feb 5, 2009, 4:00 AM
ManagementScope
Scope = null; ConnectionOptions ConnOptions = null; ObjectQuery ObjQuery = null; ManagementObjectSearcher ObjSearcher = null; try{
ConnOptions =
new ConnectionOptions();ConnOptions.Impersonation =
ImpersonationLevel.Impersonate;ConnOptions.EnablePrivileges =
true; //local machine if (machineName.ToUpper() == Environment.MachineName.ToUpper()){
Scope =
new ManagementScope(@"\ROOT\CIMV2", ConnOptions);}
else{
//remote machineConnOptions.Username = username;
ConnOptions.Password = password;
Scope =
new ManagementScope(@"\\" + machineName + @"\ROOT\CIMV2", ConnOptions);}
Scope.Connect();
ObjQuery =
new ObjectQuery("SELECT * FROM Win32_OperatingSystem");ObjSearcher =
new ManagementObjectSearcher(Scope, ObjQuery); foreach (ManagementObject operatingSystem in ObjSearcher.Get()){
MessageBox.Show("Caption = " + operatingSystem.GetPropertyValue("Caption")); MessageBox.Show("Version = " + operatingSystem.GetPropertyValue("Version")); //Shutdown // ManagementBaseObject outParams = operatingSystem.InvokeMethod("Start", null, null); ManagementBaseObject outParams = operatingSystem.InvokeMethod("Shutdown", null, null);}
}
catch (Exception ex){
MessageBox.Show("Error : " + ex.Message);}
is to shutdown machine, ,i dontknow how to restart remote machine