.ps1ファイルはセキュリティの関係上、標準の状態ではエクスプローラーなどからダブルクリックで直接起動することができないため少々扱いづらくなっています。
EXE ファイルにすることによって直接起動できるようになります。
SeleniumBasicをダウンロードしてきてサイレントでインストールするスクリプト
EXE化したいスクリプトを用意します。
今回は実用をかねてSeleniumBasicをネットからダウンロードしてきてサイレントインストールさせてみます。
InstallSeleniumBasic.ps1
Invoke-WebRequest "https://github.com/florentbr/SeleniumBasic/releases/download/v2.0.9.0/SeleniumBasic-2.0.9.0.exe" -OutFile ".\SeleniumBasic-2.0.9.0.exe"
SeleniumBasic-2.0.9.0.exe /VERYSILENT
.ps1ファイルをEXE化
Windowsキー + Rを押下して iexpress と入力。
軽量版IEが立ち上がる訳ではありません。

「次へ」をクリック

「次へ」をクリック

アプリケーションのタイトルを入力するのですがここは何でもいいです。

「次へ」をクリック

「次へ」をクリック

Power Shell Script のスクリプトファイルを指定します。
C:\work\InstallSeleniumBasic.ps1 を指定しました。

赤字の部分に先ほどのスクリプトファイル名を入力します。
ここは今回の設定のキモです。
powershell.exe -executionpolicy bypass -file InstallSeleniumBasic.ps1

「次へ」をクリック

「次へ」をクリック

EXE 化した後のファイル名を入力します。
スクリプトファイルの拡張子をEXE に変えたものでもいいですが、ここはあえて別のファイル名にしてみました。
C:\work\SilentInstallSeleniumBasic.exe

EXE実行後に再起動するかどうか指定します。
セットアップの自動化などをIexpressで行う場合などに使えそうです。
ここは単にEXE化なのでNo restartを指定します。

Don’t saveを選択して「次へ」をクリック
「次へ」をクリック

「完了」をクリック

powershell スクリプトを EXE 化することができました。

コメント