0

Windows サービスをインストールする Win2k8R2 サーバー、Web Edition でプログラムをリモートで開始したいと考えています。

サービスのインストールは、「screen>0」がある場合にのみ可能です。これは、ユーザーがログインする必要があることを意味します(ログインダイアログウィンドウが「screen 0」を表していることをどこかで読みました。ここで間違っている場合は修正してください)。画面を表示するために、RDP 接続を開き、すべてをサイレント インストールする setup exe をトリガーします。

すでに Windows Server 2003 で実行できるようにしました。2008 R2 では動作しなくなりました。私は、私が望むものを達成するための何らかのセキュリティポリシー、またはまったく別の手法さえあると思います。

コードは次のとおりです。

this.axMsRdpClient7 = new AxMSTSCLib.AxMsRdpClient7();

// ... some GUI stuff happens here..

axMsRdpClient7.Server = hostname;
axMsRdpClient7.UserName = username;
axMsRdpClient7.AdvancedSettings.Compress = -1;
axMsRdpClient7.AdvancedSettings2.DisplayConnectionBar = true;
axMsRdpClient7.AdvancedSettings7.ClearTextPassword = userpassword;
axMsRdpClient7.AdvancedSettings2.EncryptionEnabled = -1;

// Set start program information. vvv THIS IS NOT GOING TO BE EXECUTED vvv
axMsRdpClient7.SecuredSettings.StartProgram = executablePath + " " + arguments;
axMsRdpClient7.SecuredSettings.WorkDir = workingDirectory;

// ... here I'm attaching some events like OnDisconnect...

// Start connection
axMsRdpClient7.Connect();

// Now the startprogram should be executed, but doesn't.
// (at this time its ok that I have to manually log off to reach disconnect. Except you have a better idea to disconnect after startprogram finishes)
while (axMsRdpClient7.Connected != 0)
{
    Application.DoEvents();
    Thread.Sleep(1);
}

// End connection
axMsRdpClient7.Disconnect();

StartProgram が実行されていない理由を知っている人はいますか? エラーはありません。起動しないだけです。

または、サービスをリモートでインストールするためのより良い方法を知っている人はいますか?

前もって感謝します!

4

1 に答える 1

1

Disconnect() を呼び出す必要はありません。StartProgram アプローチを使用する場合、以前は「代替シェル」アプローチと呼ばれていたものを使用しています。これは、プログラムが終了すると、セッションが自動的に閉じられる/切断されることを意味します。

http://msdn.microsoft.com/en-us/library/ms861803.aspxを参照して、「AlternateShell」を検索してください。

私は最近、StartProgram パラメーターを使用して Windows 2008 RDS セッションを開始する ActiveX ライブラリを作成しました。RDS セッションの開始時に自動的に開始されるプログラムをユーザーが閉じると、RDS セッションは自動的に終了します。したがって、ループ メカニズムや、アプローチでの Disconnect() の呼び出しは必要ありません。

私のコードでは、ユーザー資格情報としてドメインも指定しています。ユーザー アカウントは Windows ドメイン アカウントですか? その場合は、おそらくそれも指定する必要があります。

さらに、次のパラメーターを設定します。

// server authentication is required - set Auth level to 2
AdvancedSettings7.AuthenticationLevel := 2;
// use CredSsp if the client supports it.
AdvancedSettings7.EnableCredSspSupport := True;
// setting PublicMode to false allows the saving of credentials, which prevents
// prompting the user to log in
AdvancedSettings7.PublicMode := False;

HTH

于 2012-04-27T15:41:00.973 に答える