以下のコードは32ビットマシンで完全に機能しますが、64ビットマシンでコードをテストしました。64ビットバージョンのcscript.exeを呼び出していたので、コードが機能することを期待していました。
代わりに、コードはスクリプトを実行するポイントに到達し、正確に30秒間待機してから、スクリプトを終了し、プログラムの残りの部分を続行します。ただし、スクリプトは実行されていないようです(手動で実行すると正常に動作します)。
using (var ServerProcess = new System.Diagnostics.Process())
{
var fileInformation = new FileInfo(VBScriptToRun);
string processFileName = IntPtr.Size == 8 ? @"c:\windows\sysWOW64\cscript.exe " : @"c:\windows\system32\cscript.exe ";
string processWorkDir = IntPtr.Size == 8 ? @"c:\windows\sysWOW64\" : @"c:\windows\system32\";
string processArguments = fileInformation.FullName;
ServerProcess.StartInfo.FileName = processFileName;
ServerProcess.StartInfo.WorkingDirectory = processWorkDir;
ServerProcess.StartInfo.Arguments = processArguments;
ServerProcess.StartInfo.CreateNoWindow = false;
ServerProcess.StartInfo.UseShellExecute = false;
ServerProcess.StartInfo.RedirectStandardOutput = true;
ServerProcess.StartInfo.LoadUserProfile = true;
EventLogger.Instance.WriteInformation("Total Integration Service Processing File: Starting to launch the specified program");
try
{
ServerProcess.Start();
ServerProcess.WaitForExit();
}catch(Exception e)
{
EventLogger.Instance.WriteInforamtion("Error running script: " + e)
}