0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

バッチファイルからPowerShellを管理者で実行する

Posted at

ps1ファイルの先頭で権限を上げて実行するコマンドを挿入するとか「-Verb RunAs」をつけるとか有りましたがそれだけだとうまく動かなかったので…。

コマンドプロンプトは管理者権限でなくても大丈夫。
管理者権限で開くときにカレントディレクトリがデフォルトのところになるので諸々のパスは絶対パスで指定する必要がある。

実行.bat
powershell -Command "Start-Process powershell.exe -ArgumentList '-ExecutionPolicy Bypass -File \"%~dp0管理者権限で実行.ps1\"' -Verb RunAs"

PowerShellは普通に書けばOK

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?