3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

管理者権限でファイルを編集するbat

Last updated at Posted at 2016-02-19

概要

tnsnames.oraをちょくちょくいじることがあるんですが、深い場所にあるし管理者権限で開かなきゃいけなかったりとけっこう手間になる。

コード

下記のような内容を書いたbatをつくり、任意の場所に置いてダブルクリックで実行する。

.bat
powershell -command "Start-Process -Verb runas \"エディタのパス\" \"編集したいファイルのパス\""

やってることは.batの中からPowerShellを呼び出し、runasで管理者権限でエディタにファイルを渡して実行しています。

tnsnames.oraをサクラエディタで編集したいときは下記のようにしてデスクトップなんかに置く。usernameのところは置き換えてください。

edit_tnsnames.bat
powershell -command "Start-Process -Verb runas \"C:\Program Files (x86)\sakura\sakura.exe\" \"C:\app\username\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora\""
3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?