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.

[VBScript] コマンドラインから UAC 昇格

Last updated at Posted at 2014-10-27

cscript please.vbs プログラム名 とすると、管理者権限でそのプログラムを起動します。プログラム名を省略すると、CMD.EXEが起動します。

直前に投稿した「Windows で vipw っぽく、システムのデフォルト%PATH%を変更する」の副産物です。

please.vbs
Option Explicit
Dim program
If WScript.Arguments.Count <= 0 Then
    program = "CMD.EXE"
Else
    program = WScript.Arguments(0)
End If
Dim argv : argv = ""
If WScript.Arguments.Count >= 1 then
    Dim i
    For i=1 To WScript.Arguments.Count-1
        argv = argv & " " & WScript.Arguments(i)
    Next
End If
Dim shellApp : Set shellApp = CreateObject("Shell.Application")
shellApp.ShellExecute program,Trim(argv), "" , "runas"
Set shellApp = Nothing
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?