Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a .bat file that cannot allow me to set it to run as admin as required by going to the Properties box and check for Privilege checkbox.

But mine is disabled as below snapshot.

What can I do to get it enabled?

enter image description here

share|improve this question

2 Answers 2

It doesn't work because it's a batch file.

I like to use the following approach to get around this limitation:

@if (1==1) @if(1==0) @ELSE
@echo off&SETLOCAL ENABLEEXTENSIONS
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"||(
    cscript //E:JScript //nologo "%~f0"
    @goto :EOF
)
echo.Setting IP configuration to DHCP...
netsh interface ipv4 set address "Local Area Connection" dhcp
echo.Setting DNS configuration to DHCP...
netsh interface ipv4 set dnsservers "Local Area Connection" dhcp
pause
@goto :EOF
@end @ELSE
ShA=new ActiveXObject("Shell.Application")
ShA.ShellExecute("cmd.exe","/c \""+WScript.ScriptFullName+"\"","","runas",5);
@end

This would enable DHCP for a network adapter. Should be fairly easy to adjust to your needs.

share|improve this answer

I think I've got the solution for you. You need to turn off UAC and back on again:

How to turn UAC on or off

Open User Account Control Settings by going to Start > Control Panel. In the search box, type "uac" without quotes, and then click Change User Account Control settings.

Do the following:

  1. Turn off UAC - move the slider to the Never notify position, and then click OK. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation. You will need to restart your computer for UAC to be turned off.

  2. Turn on UAC - move the slider to choose when you want to be notified, and then click OK. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.

Way back I dealt with a similar issue on an .exe file and I recall trying this after some research over here. It solved my problem right away.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.