私は2台の物理マシンを持っています。最初のマシンは、2番目のマシンでbatファイルを実行したいと考えています。2番目のサーバーに共有の場所を作成し、最初のマシンから実行しようとしましたが、機能しません。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ファイルを実行する方法を知りたいですか?