Running Terminal as Admin

Answered

Howdy.

Is it possible to run the Terminal as Admin?

I'd like to delete some files every now and again through the terminal but the commands are rejected due to insufficient permissions. I assume the Terminal is being run as a standard user. 

Cheers,

Ben.

0
5 comments

What OS do you use? On Linux/Mac you could specify custom shell executable for the Terminal with a script that will call sudo before running the shell or just call sudo inside the Terminal.

On Windows you can try editing the properties of your Terminal executable (cmd.exe or make a copy of it) to always run this command as Administrator.

0
Avatar
Permanently deleted user

The solution is to run intelliJ or WebStorm or whatever other JetBrains product with admin rights; right click --> run as administrator --> that's all you need!

8
Avatar
Permanently deleted user

As Takalpa said. Running the product with admin privilege should grant you access to admin terminal as well in Windows OS.

0
Avatar
Permanently deleted user

try `sudo idea` in unix & linux

0

Would it be possible to modify the below batch file to run from within the IDE and open an admin instance within the user-level?

I can think of a ton of use cases I would love to be able to run specifically one or the other together. I use Eventghost Heavily to interact with everything, and Lcore for tons of macros and things of that nature. I usually just spawn a separate window
   

Edit: Orginally posted it in the whole script, so you can take a look if you want to.

:: Elevate.cmd - Version 4
:: Automatically check & get admin rights
:: see "https://stackoverflow.com/a/12264592/1016343" for description
::::::::::::::::::::::::::::::::::::::::::::
setlocal DisableDelayedExpansion
set cmdInvoke=1
set winSysFolder=System32
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)

ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " " >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"

if '%cmdInvoke%'=='1' goto InvokeCmd

ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
goto ExecElevation

:InvokeCmd
ECHO args = "/c """ + "!batchPath!" + """ " + args >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "%SystemRoot%\%winSysFolder%\cmd.exe", args, "", "runas", 1 >> "%vbsGetPrivileges%"

:ExecElevation
"%SystemRoot%\%winSysFolder%\WScript.exe" "%vbsGetPrivileges%" %*
exit /B

:gotPrivileges
setlocal & cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul & shift /1)
::START
::::::::::::::::::::::::::::
REM Run shell as admin (example) - put here code as you like
ECHO %batchName% Arguments: P1=%1 P2=%2 P3=%3 P4=%4 P5=%5 P6=%6 P7=%7 P8=%8 P9=%9
cmd /k %*

 

0

Please sign in to leave a comment.