私はC#コーディングが初めてです。次のことを手伝ってください。よろしくお願いします..!!!
私は次のことを試みています:
リモート サーバーでバッチ ファイルを実行する小さな C# アプリを開発しています。コードは次のとおりです。サーバーのほとんどは Windows 2008 64 ビットです。サーバーに RDP を実行すると、エラーなしでバッチ ファイルを実行できますが、実行しようとすると次のコードを使用すると、機能せず、例外はスローされませんが、結果はありません。
私のバッチファイルには次のコマンドが含まれています:
@ECHO off
echo Running Remote Commands
date/t
time /t
COPY "\\xt0022\I$\abc\RemoteProcess\testcopy.bat" D:\ab\
date/t
time /t
-
try
{
string remotemachine = "Server1";
object[] theProcessToRun = { "D:\\ab\\test2.bat" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Impersonation = ImpersonationLevel.Impersonate;
theConnection.EnablePrivileges = true;
ManagementScope theScope = new ManagementScope("\\\\" + remoteMachine + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);
}
catch (Exception ex)
{
}
コードをデバッグすると、「派生 = 関数の評価がタイムアウトしました」と表示されます。
これを RUNAS で実行する必要がありますか? はいの場合..誰かがそれらのコードまたはメソッドで私を助けることができます..?
皆さん、ありがとうございました..!