10

Windows 2003サーバーにスクリプトを起動させて、別のWindowsServer2008コンピューターで別のスクリプトを起動させたいのですが。

Powershellでそれができると言われましたが、それで問題ありませんが、より具体的な詳細が必要です。

誰かがこれについて何かヒントがありますか?

ありがとう!

4

5 に答える 5

14

SysInternalsのpsexec

于 2009-05-14T01:46:23.433 に答える
6

ATコマンドの構文を調べてください。これを使用して、リモートマシンで実行するプロセスをスケジュールできます。

ATコマンドは、指定された日時にコンピューター上で実行されるコマンドとプログラムをスケジュールします。ATコマンドを使用するには、Scheduleサービスが実行されている必要があります。

AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]
AT [\\computername] time [/INTERACTIVE]
    [ /EVERY:date[,...] | /NEXT:date[,...]] "command"

\\computername     Specifies a remote computer. Commands are scheduled on the
                   local computer if this parameter is omitted.
id                 Is an identification number assigned to a scheduled
                   command.
/delete            Cancels a scheduled command. If id is omitted, all the
                   scheduled commands on the computer are canceled.
/yes               Used with cancel all jobs command when no further
                   confirmation is desired.
time               Specifies the time when command is to run.
/interactive       Allows the job to interact with the desktop of the user
                   who is logged on at the time the job runs.
/every:date[,...]  Runs the command on each specified day(s) of the week or
                   month. If date is omitted, the current day of the month
                   is assumed.
/next:date[,...]   Runs the specified command on the next occurrence of the
                   day (for example, next Thursday).  If date is omitted, the
                   current day of the month is assumed.
"command"          Is the Windows NT command, or batch program to be run.
于 2009-05-14T01:33:37.553 に答える
4

使用する最も簡単な方法は2つのステップになります

a。cygwinをリモートPCにインストールする

b。ssh hudson@mcsを実行します'/cygdrive/c/path_to_script.bat'

于 2013-11-25T13:42:33.597 に答える
2

について言えばPsExec、代わりにCygwin/OpenSSHを使用することを強くお勧めします。

SSHには複数の利点があります(PsExecカスタムサービスなどのツールよりも)。
たとえば、これらの/コマンドラインの機能を使用しPsExecて実装してみてください。bashssh

ssh user@remotehost "find . -name something" 2> all.errors.txt
ssh user@remotehost "grep -r something ."
if [ "$?" == "0" ]
then
    echo "FOUND"
else
    echo "NOT FOUND"
fi

幸運を!

  • SSHは、検査のためにリモートstdout / stderr / exitステータスをローカルシェルに転送します(!)
    リモート実行をローカルスクリプトのロジックに統合するためのキラー機能と一般的な要件)

  • Cygwin / OpenSSHは、標準のPOSIXシェル環境を提供します
    (効率的な時間投資、基本的なツール、クロスプラットフォーム対応、互換性のある習慣など)

  • すべてのネイティブWindowsアプリケーションを引き続き/常に実行できます(プロセッサによるファイル
    の自動実行を含む)*.batcmd

  • 公開鍵を使用してパスワードなしの認証を構成できます
    (無人の自動化されたタスクについて考えてください)


ヒント

最初に問題があった要件が1つありました。
バックグラウンドsshdサービスは、ユーザーのグラフィカルセッションでアプリを実行する必要がありました
(アプリケーションウィンドウをデスクトップ環境に表示するため)。

私にとって受け入れられる解決策は、ユーザーのGUIセッションで直接sshdサービスを実行することでした (ユーザーがログインすると自動的に開始し、リンクをたどって構成ファイルの変更を確認します)。

/usr/sbin/sshd -f /home/user/sshd_config
于 2013-05-23T17:23:17.000 に答える
0

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Q_22959948.htmlから受け入れられているソリューションは次のとおりです。

私が提供するのは、パラメーターを受け取るスクリプトでした...この場合は4が必要です。1)サーバー:-serverを渡すと、その1つのサーバーのみが実行されます。2)リスト:サーバーのリストファイルを提供できます。3)サービス:変更するサービスの名前4)詳細:ここでは使用されません。

次のコードで変更したいくつかの間違いがありました。コードをカットアンドペーストして、Set-RemoteService.ps1というファイルに貼り付けます。スクリプトを実行するようにexecutionpolicyを設定してください...デフォルトでは実行されません。これを行うには、set-executionpolicyコマンドレットを使用します。PS> Set-Executionpolicy "RemoteSigned"を実行して、実行するスクリプトを実行しますPS> C:\ PathToScript \ Set-RemoteService.ps1 -list c:\ ServerList.txt -service "DHCP"

######################### Param($ server、$ list、$ service、[switch] $ verbose)

if($ Verbose){$ VerbosePreference = "Continue"} if($ list){foreach($ srv in(get-content $ list)){$ query = "Select * from Win32_Service where Name ='$ service'" $ myService = get-WmiObject -query $ query -computer $ srv $ myService.ChangeStartMode( "Automatic")$ myService.Start()}} if($ server){$ query = "Select * from Win32_Service where Name ='$ service '"$ myService = get-WmiObject -query $ query -computer $ server $ myService.ChangeStartMode(" Automatic ")$ myService.Start()}

于 2009-05-14T01:31:05.717 に答える