Runas Administrator
1. Command Mode:
路徑中的資料夾名稱沒有空白時:
runas /user:administrator "regedit /s c:\test.reg"
路徑中的資料夾名稱有空白時:
runas /user:Administrator "regedit.exe /s \"c:\Documents and Settings\James\desktop\test.reg\""
接著請依照系統提示輸入 所設定的 runas 身分 的密碼.
2. C#:
System.Diagnostics.Process processTemp;
processTemp = new System.Diagnostics.Process();
strCmdLine = "/c regedit.exe /s DisableTaskMgr.reg ";
System.Security.SecureString sstrPassword = new System.Security.SecureString ();
sstrPassword.AppendChar('0');
sstrPassword.AppendChar('3');
sstrPassword.AppendChar('@');
sstrPassword.AppendChar('5');
sstrPassword.AppendChar('7');
sstrPassword.AppendChar('8');
sstrPassword.AppendChar('@');
sstrPassword.AppendChar('9');
sstrPassword.AppendChar('9');
sstrPassword.AppendChar('0');
sstrPassword.AppendChar('0');
string strDomainName =System.Windows.Forms.SystemInformation.ComputerName;
System.Diagnostics.Process.Start("CMD.exe", strCmdLine, "Administrator", sstrPassword, strDomainName);
processTemp.Close();
}