Skip to content

Instantly share code, notes, and snippets.

@tnhung2011
Created December 18, 2025 10:58
Show Gist options
  • Select an option

  • Save tnhung2011/90b403120bf4699d49c97627cb132ecb to your computer and use it in GitHub Desktop.

Select an option

Save tnhung2011/90b403120bf4699d49c97627cb132ecb to your computer and use it in GitHub Desktop.
I don't know if anyone has posted this. This script elevates your program without using temporary VBScript file or PowerShell.
@if (@X == @Y) @end /*
@echo off
setlocal enableextensions enabledelayedexpansion
set rargs=
for /f usebackq^ tokens^=1*^ eol^= %%a in ('%*') do set rargs=%%b
cscript //nologo //e:jscript "%~f0" %1
exit /b
*/
WScript.CreateObject("Shell.Application").ShellExecute(WScript.Arguments(0), WScript.CreateObject("WScript.Shell").Environment("Process").Item("rargs"), "", "runas");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment