Use the inbuilt Windows' VB.Net compiler to elevate.
RunAsAdminConsole.exe
creates an elevated console or runs a command leaving the console elevated. The program prompts for credentials. Copy following three text files into a folder and double click the batch file.
The advantage of this put in a shortcut is the admin icon overlay appears on the shortcut's icon. If you just tick Run As Admin in compatibility tab it doesn't get the icon overlay.
REM Three files follow
REM RunAsAdminConsole.bat
REM This file compiles RunAsAdminconsole.vb to RunAsAdminconsole.exe using the system VB.NET compiler.
REM Runs a command elevated using a manifest OR elevates the current console without parameters.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc "%~dp0\RunAsAdminconsole.vb" /win32manifest:"%~dp0\RunAsAdmin.manifest" /out:"%~dp0\RunAsAdminConsole.exe" /target:exe
REM To use
rem RunAsAdminconsole
pause
;RunAsAdminConsole.vb
imports System.Runtime.InteropServices
Public Module MyApplication
Public Sub Main ()
Dim wshshell as object
WshShell = CreateObject("WScript.Shell")
Shell("cmd.exe /k " & Command())
End Sub
End Module
Name this file RunAsAdmin.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="*"
name="Color Management"
type="win32"
/>
<description>Serenity's Editor</description>
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
From https://winsourcecode.blogspot.com/2019/12/rem-three-files-followrem.html
powershell -Command "Start-Process cmd -ArgumentList '/s /k pushd \"%V\"' -Verb RunAs"