Elevated Privilege in XP

484 views Asked by At

Does anyone know how to do this on xp using tha batch command, this will be tested in the limited user. I have found something and it works fine in W7 but when I tried it on XP it does not work.

3

There are 3 answers

6
v20100v On BEST ANSWER
cls
@echo off


:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    cls
    echo ... restart console with privilege admin ...
    pause>nul
    goto UACPrompt
) else ( 
    echo ... ok jedi ...
    goto gotAdmin 
)

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
    "%temp%\getadmin.vbs"
    exit /B
:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------
0
Ansgar Wiechers On

User Account Control (UAC) was introduced with Windows Vista. It's not available in earlier versions like XP.

In XP, when you are member of the Administrators group, you have admin privileges all of the time, so there's no need for elevation. If you're not a member of the Administrators group you need to authenticate as a different user, which can be done via the runas command:

runas /user:DOMAIN\ADMIN_USER some_command

With that said, support for Windows XP ended on April 8 this year, so you shouldn't be using it anymore. In fact, you should have migrated off XP a long time ago.

0
lx42.de On

The nir command tools have such a functionality too:

http://nircmd.nirsoft.net/runas.html

nircmd runas