我有兩臺物理機器。第一臺機器想要在第二臺機器上執行一個bat文件。我在第二臺服務器上創建一個共享位置,並嘗試從第一臺機器運行它,但它不起作用。 bat文件可以正確運行在本地機器上。如何在遠程服務器上執行bat文件?
這是bat文件內部代碼的一個例子。這只是一個創建文件的蝙蝠。
echo. 2>EmptyFile.txt
這是我用來執行bat文件的代碼。
private static void ExecuteBatFile()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
System.Security.SecureString ssPassword = new System.Security.SecureString();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = @"\\my_remote_server\my_bat.bat";
proc.StartInfo.Domain = "my_domain";
proc.StartInfo.UserName = "my_username";
Console.Write("Enter your password: ");
string password = Console.ReadLine();
for (int x = 0; x < password.Length; x++)
{
ssPassword.AppendChar(password[x]);
}
proc.StartInfo.Password = ssPassword;
proc.Start();
}
我想知道如何在遠程服務器上運行bat文件?
http://www.codeproject.com/Articles/31113/Create-a-遠程過程使用WMI-in-C –