把這篇
[Win] NET TIME 內容,改成用 C# 來呼叫,進行校時
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
string ServerName = "Win2012R2";
proc.StartInfo.UseShellExecute = true; // true 為預設值
proc.StartInfo.FileName = "NET.EXE";
proc.StartInfo.Arguments = @"TIME \\" + ServerName + " /SET /YES";
// 用 Admin 權限執行該語法,但要注意
// Process.StartInfo.UseShellExecute = true (預設)狀態下,
// Verb 才會有作用
proc.StartInfo.Verb = "runas";
proc.Start();
proc.Close();
}
}
}
1 則留言:
good
張貼留言