2

サービスを StatusType = 'Automatic' に設定する Powershell スクリプトを作成しました。しかし、スクリプトを実行すると、実際には StatusType = 'Automatic (Delayed Start)' が設定されます。以下は私のスクリプトです: -

Set-Service -name 'XXXXX Data Import Service' -startupType automatic

statusType を 'Automatic' に設定するのを手伝ってくれる人はいますか?

4

3 に答える 3

1

たぶん10勝。set-service ではできませんでした。明示的なサービスの起動状態には sc.exe を使用する必要があります。

sc config "XXXXX Data Import Service" start= auto
于 2016-12-07T13:34:10.230 に答える
1

次のように実行できます。スクリプトで言及したコメントを参照してください。それに応じて使用してください。

#$server is the server name you want to change
#$service is the service name
$command = "sc.exe \\$server config $service start= delayed-auto" ## For delayed Auto
$command = "sc.exe \\$server config $service start= auto"## For Automatic
$output = invoke-expression -command $command
write-host $server " " $output

注: start=delayed-auto の間のスペースは重要です。

于 2016-12-07T14:16:44.107 に答える