run cmd as administrator from cmd code example
Example 1: run cmd as administrator command line
powershell -command "start-process cmd -verb runas"
Example 2: how to run cmd run administrator using script
@echo off
break off
title C:\Windows\system32\cmd.exe
cls
:cmd
set /p cmd=C:\Enter Command:
%cmd%
echo.
goto cmd
Example 3: how to run cmd run administrator using script
if "%~s0"=="%~s1" ( cd %~sp1 & shift ) else (
echo CreateObject^("Shell.Application"^).ShellExecute "%~s0","%~0 %*","","runas",1 >"%tmp%%~n0.vbs" & "%tmp%%~n0.vbs" & del /q "%tmp%%~n0.vbs" & goto :eof
)
Example 4: run command for admin cmd
win + x + a