Cmd admin to no admin

Asked

Viewed 35 times

0

I saw in this link that it is possible to change to Adm in Win7.
Creating a . BAT and executing the code with administrator privileges

But I wanted to know how to change back so no one would notice that all the time to open it normal will appear Admin

@echo off

:init
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.
ECHO **************************************
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)

REM Run shell as admin

1 answer

0

Explaining, what happened versus what you saw...

I saw in this link that it is possible to change to Adm in Win7.

  • No, you didn’t see this, what you saw was just the execution of a code that checks if the user who invoked it is a user with an administrator credential or a member of that group, and if this user isn’t (doesn’t have that credential), will request a high permission from a user who has it (administrator/or other member of the group of administrators), only then follow up the executions at the level of a high permissioning administrator, but if that user does not have such a credential, it ends immediately without continuing the execution, which obligatorily requires such permission in its execution:
NET FILE 1>NUL 2>NUL 
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )``
  • It’s the same as testing and behaving:`
NET FILE 1>NUL 2>NUL 
if '%errorlevel%' == '0' ('tenho privilégios') else ('obter privilégios')
 
if '%errorlevel%' == '0' tenho privilégios' == '0' sou adminstrador

if '%errorlevel%''0' obter privilégios == preciso ser adminstrador // ou ter aprovação de um

But I wanted to know how to change back so no one would notice that all the time to open it normal will appear Admin

1. Be the administrator or a user member of that group

2. Add a script in the task manager by adding your credential for the runs by scheduling the required runs as needed

3. Understand that without answering the items 1 & 2, execution will not be possible, as there is no code that can "promote the user without administrator status" for a user with the administrator status.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.