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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
asha2 reputationPosted Feb 4, 2009, 11:00 PM EST
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
hung cuong nguyen2 reputationPosted May 27, 2010, 2:02 AM EDT
Thanks
jayakrishnan Morayur156 reputationPosted Mar 18, 2011, 2:37 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted Mar 18, 2011, 4:15 AM EDT
I used your method but on local machine it just show command prompt and nothing else
and remote didn't get shutdown