If UAC is enabled on the computer, something like this should work:
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute WScript.FullName _
, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
WScript.Quit
End If
'actual code
More Related Contents:
- Is there a way to find the length of a string in Batch/PowerShell Script/VBScript? [closed]
- How can I auto-elevate my batch file, so that it requests from UAC administrator rights if required?
- Can Windows’ built-in ZIP compression be scripted?
- Installing application for currently logged in user from Inno Setup installer running as Administrator
- How to make a batch file delete itself?
- How do I set a Windows scheduled task to run in the background? [closed]
- How to read from a text file using VBScript?
- How to create a Run As Administrator shortcut using Powershell
- What precisely does ‘Run as administrator’ do? [closed]
- Why does ping work without administrator privileges?
- How to prevent uninstaller elevating for Standard Windows 10 user?
- What’s the environment variable for the path to the desktop?
- How to control Windows system volume using JScript or VBScript?
- How to run a makefile in Windows?
- Command-line tool for finding out who is locking a file
- How do I add to the Windows PATH variable using setx? Having weird problems
- Windows batch: sleep [duplicate]
- While loop in batch
- How can I tell if a window has focus? (Win32 API)
- Windows shell command to get the full path to the current directory?
- NPM package ‘bin’ script for Windows
- How do I create a manifest file to launch application with admin privileges?
- How to change default sound playback device programmatically?
- Powershell script does not run via Scheduled Tasks
- How to install Qt on Windows after building?
- Foolproof way to check for nonzero (error) return code in windows batch file
- ERRORLEVEL vs %ERRORLEVEL% vs exclamation mark ERRORLEVEL exclamation mark
- Create a list or an array and print each item in Windows Batch
- What are these strange environment variables?
- WSL run linux from windows without spawning a cmd-window