5
2

More than 5 years have passed since last update.

管理者権限が必要なコマンドをダブルクリックで実行したい

Posted at

サービスの起動停止をコマンドから行いたかったのですが、
「右クリック→管理者として実行」がめんどくさかったのでダブルクリックで実行する方法を調べました。

COMMAND部分を使用したいコマンドに変更して使用してください。
例ではpostgresqlサービスの立ち上げを行っています。

cmdで実行

exsample.dat
set COMMAND=Start-Service -Name postgresql-x64-9.4
@powershell -NoProfile -ExecutionPolicy unrestricted -Command Start-Process powershell.exe \"%COMMAND%\" -Verb runas

PowerShellで実行

exsample.ps1
set COMMAND=Start-Service -Name postgresql-x64-9.4
Start-Process powershell.exe \"%COMMAND%\" -Verb runas

参考記事
Windowsでsudoしたい

5
2
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
5
2