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.
Asked
Active
Viewed 435 times
3 Answers
2
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.

Ansgar Wiechers
- 193,178
- 25
- 254
- 328
1
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"
:--------------------------------------

v20100v
- 696
- 4
- 11
-
Could you give us more information ? you can find info on calcs.exe here : http://www.techrepublic.com/article/use-caclsexe-to-view-and-manage-windows-acls/ – v20100v Nov 19 '14 at 15:07
-
I don't think the runas verb existed in XP. – Harry Johnston Nov 20 '14 at 00:25
-
@HarryJohnston The verb did exist, but worked differently, since there was no UAC. – Ansgar Wiechers Nov 20 '14 at 07:56
-
anyway, I have another issue. We wont longer use this on xp. – xka Nov 20 '14 at 10:39
-
I have another issue that needs to check if the user(limited) did not log in as admin using the elevated privilege then the batch will not execute the program.exe. Else if the user login as an admin in elevated privilege then this will continue the execution of the program.exe, is this possible? – xka Nov 20 '14 at 10:41
-
@CireGarcia: [already asked and answered](http://stackoverflow.com/questions/7985755/how-to-detect-if-cmd-is-running-as-administrator-has-elevated-privileges). – Harry Johnston Nov 20 '14 at 18:54
0
The nir command tools have such a functionality too:
http://nircmd.nirsoft.net/runas.html
nircmd runas

lx42.de
- 418
- 2
- 4