vbsから管理者としてvbsを実行する方法は?



How Run Vbs Administrator From Vbs



解決:

コンピューターでUACが有効になっている場合は、次のように機能するはずです。

WScript.Arguments.Named.Exists( 'elevate')Then CreateObject( 'Shell.Application')。ShellExecute WScript.FullName _、 '' ''&WScript.ScriptFullName& '' '/ elevate'、 ''、 ' runas '、1 WScript.Quit EndIf'実際のコード 

これをファイルの先頭に追加します。



Set WshShell = WScript.CreateObject( 'WScript.Shell')If WScript.Arguments.Length = 0 Then Set ObjShell = CreateObject( 'Shell.Application')ObjShell.ShellExecute'wscript.exe '_、' '' '&WScript。 ScriptFullName& '' 'RunAsAdministrator' 、、 'runas'、1 WScript.Quit End if 

楽しいlilバッチファイル

@set E = ECHO&set S = SET&set CS = CScript // T:3 // nologo%〜n0.vbs / REALTIME ^> nul ^&timeout 1 / NOBREAK ^> nul ^&del / Q%〜n0.vbs&CLS @%E%off&color 4a&title%〜n0&%S%CX = CLS ^&EXIT&%S%BS = ^>%〜n0.vbs&%S%G = GOTO&%S%H = shell&AT> NUL IF%ERRORLEVEL%EQU 0 (%G%2)ELSE(そうでない場合 '%minimized%' == ''%G%1)%S%minimized = true&start / min cmd / C '%〜dpnx0'&%CX%:1%E %% S %% H%= CreateObject( '%H%.Application'):%H%。%H%Execute '%〜dpnx0' ,, '%CD%'、 'runas'、1:%S %% H%= noneth%BS%&%CS%&%CX%:2%E %% 〜dpnx0 fvcLing管理者モードルックアップ&wmicプロセスここで、name = 'cmd.exe' CALL setpriority'realtime '&timeout 3 / NOBREAK> nul: 3%E%x = msgbox( 'end of line'、48、 '%〜n0')%BS%&%CS%&%CX%