Continue batch after UAC disable
Moderator: DosItHelp
Re: Continue batch after UAC disable
Sorry it was not removed i just did not copy the whole thing. This is getting to be a pretty big batch with all my other stuff i have in it. My problem is i still cannot get past the registry entry. I have had no luck fixing that issue yet. Here is the first part of my code.
rem @ECHO OFF
:: Disable UAC
:: This check for the Registry changes made or not yet
:: if the changes is made then goto after_reboot
:: if not make that mean this is the first time to run
:: and it make it and then goto first_time
For /F %%a in ('REG Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA') DO (
IF %%a==0 ( Goto After_Reboot
) Else ( Goto First_Time )
)
:First_Time
:: 1st Disable UAC from Registry
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f >nul
pause
:: 2nd take a copy of this batch to start up folder
:: Get USB drive letter
:: Use vol f: to get serial number
:: To point to a program on the USB drive use %drv%:\apps\program.exe
setlocal
For %%A in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) Do (
if exist "%%A:\" (for /f "tokens=5 delims= " %%B in ('Vol %%A:') Do if %%B==B729-02C8 set drv=%%A)
)
echo %drv%
pause
Copy /Y "%drv%:\NewMachineSetup.bat" "C:\users\%username%\AppData\Roaming\Microsoft
\Windows\Start Menu\Programs\Startup\NewMachineSetup.bat"
Pause
:: 3rd Now Rebooting the system
Pause
Shutdown -r -f -t 2
:After_Reboot
:: put your commands here to be done after the PC Restart
rem @ECHO OFF
:: Disable UAC
:: This check for the Registry changes made or not yet
:: if the changes is made then goto after_reboot
:: if not make that mean this is the first time to run
:: and it make it and then goto first_time
For /F %%a in ('REG Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA') DO (
IF %%a==0 ( Goto After_Reboot
) Else ( Goto First_Time )
)
:First_Time
:: 1st Disable UAC from Registry
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f >nul
pause
:: 2nd take a copy of this batch to start up folder
:: Get USB drive letter
:: Use vol f: to get serial number
:: To point to a program on the USB drive use %drv%:\apps\program.exe
setlocal
For %%A in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) Do (
if exist "%%A:\" (for /f "tokens=5 delims= " %%B in ('Vol %%A:') Do if %%B==B729-02C8 set drv=%%A)
)
echo %drv%
pause
Copy /Y "%drv%:\NewMachineSetup.bat" "C:\users\%username%\AppData\Roaming\Microsoft
\Windows\Start Menu\Programs\Startup\NewMachineSetup.bat"
Pause
:: 3rd Now Rebooting the system
Pause
Shutdown -r -f -t 2
:After_Reboot
:: put your commands here to be done after the PC Restart
Re: Continue batch after UAC disable
Hi, Here is A Fix for the code the error was in the for loop and the compared number it should look like this:
the new changes is in the red
Give it a try and tell us.
For /F "tokens=3 delims= " %%a in ('REG Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA') DO (
IF %%a==0x0 ( Goto After_Reboot
) Else ( Goto First_Time )
)
the new changes is in the red
Give it a try and tell us.
Re: Continue batch after UAC disable
Still getting access denied. I i right click and run as administrator it comes up with a UAC prompt asking if this is OK. I am using an admin account. I double checked under users and the account i am using is marked as administrator.
rem @ECHO OFF
:: Disable UAC
:: This check for the Registry changes made or not yet
:: if the changes is made then goto after_reboot
:: if not make that mean this is the first time to run
:: and it make it and then goto first_time
For /F "tokens=3 delims= " %%a in ('REG Query HKLM\SOFTWARE\Microsoft\Windows
\CurrentVersion\Policies\System /v EnableLUA') DO (
IF %%a==0x0 ( Goto After_Reboot
) Else ( Goto First_Time )
)
C:\Users\p1tech\Desktop>rem @ECHO OFF
C:\Users\p1tech\Desktop>For /F "tokens=3 delims= " %a in ('REG Query HKLM\SOFTWA
RE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA') DO (IF %a ==
0x0 (Goto After_Reboot ) Else (Goto First_Time ) )
C:\Users\p1tech\Desktop>(IF 0x1 == 0x0 (Goto After_Reboot ) Else (Goto First_Ti
me ) )
C:\Users\p1tech\Desktop>REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f 1>nul
ERROR: Access is denied.
C:\Users\p1tech\Desktop>pause
Press any key to continue . . .
rem @ECHO OFF
:: Disable UAC
:: This check for the Registry changes made or not yet
:: if the changes is made then goto after_reboot
:: if not make that mean this is the first time to run
:: and it make it and then goto first_time
For /F "tokens=3 delims= " %%a in ('REG Query HKLM\SOFTWARE\Microsoft\Windows
\CurrentVersion\Policies\System /v EnableLUA') DO (
IF %%a==0x0 ( Goto After_Reboot
) Else ( Goto First_Time )
)
C:\Users\p1tech\Desktop>rem @ECHO OFF
C:\Users\p1tech\Desktop>For /F "tokens=3 delims= " %a in ('REG Query HKLM\SOFTWA
RE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA') DO (IF %a ==
0x0 (Goto After_Reboot ) Else (Goto First_Time ) )
C:\Users\p1tech\Desktop>(IF 0x1 == 0x0 (Goto After_Reboot ) Else (Goto First_Ti
me ) )
C:\Users\p1tech\Desktop>REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f 1>nul
ERROR: Access is denied.
C:\Users\p1tech\Desktop>pause
Press any key to continue . . .
Re: Continue batch after UAC disable
remove the Rem befor @echo off in the first line
u can turn the UAC by:
click start menu and write in the search uac
then open the first program and move the slide down to the end
then restart that will set the uac to none and teh value of the registry key we are testing will be 0x0
so teh batch will go automatically to the After_reboot section and run your commands
u can turn the UAC by:
click start menu and write in the search uac
then open the first program and move the slide down to the end
then restart that will set the uac to none and teh value of the registry key we are testing will be 0x0
so teh batch will go automatically to the After_reboot section and run your commands
Re: Continue batch after UAC disable
the whole reason i am doing this is so this batch will turn off the UAC without user intervention. That is the purpose of the code you wrote. The only issue is how to elevate the command prompt so we do not get the uac popup
Re: Continue batch after UAC disable
the whole reason i am doing this is so this batch will turn off the UAC without user intervention
Sorry I forgot
The only issue is how to elevate the command prompt so we do not get the uac popup
I Tried to do that before but no luck yet, The only thing that can do such a thing is an exploit but no way you can do exploits with batch
but as you said before right click on the batch and run as admin should make the batch run with admin rights.
so there is no need to put the First_Time section or even the If statement.
All what you have to do is just put your commands in a batch then when starting it right click and Run as administrator, Or
run the batch from elevated cmd window not by clicking the batch.
Re: Continue batch after UAC disable
yes I can do that and run the batch but if you take out the first_time statement the reg setting will not get changed and the UAC will not get shut off. The only way to run the batch as an admin is to create a shortcut and tell it to run with admin rights. Thats when we get the UAC popup. Since UAC is still turned on administrators run in user mode. So you get the popup. The question being is how to run the batch so we do not get that popup? There has to be a way to suppress that stupid popup. I think thats the last thing holding us back
Re: Continue batch after UAC disable
If you right click and run as administrator you already running with privilage so you don't need to re-run with privelage
Re: Continue batch after UAC disable
then how do i keep this UAC box from popping up?
Re: Continue batch after UAC disable
gymiv wrote:then how do i keep this UAC box from popping up?
you don't until you disable UAC as far as I know.
Re: Continue batch after UAC disable
Open regedit and browse the above key, right click and select -> permissions.gymiv wrote:>REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t "REG_DWORD" /d "0" /f 1>nul
ERROR: Access is denied.
Is your username/group listed, can you access the list at all ?
You can edit permissions with 'setACL.EXE', you may need to take ownership of the key first.
http://setacl.sourceforge.net by Helge Klein
Regards,
Re: Continue batch after UAC disable
my specific login is not in there but the administrators group is in there. the account i am using is marked as administrator under users. The administrator group in the permissions has full control
Re: Continue batch after UAC disable
now this i do not get. I enabled the administrator account and reran the bat. It runs fine. So even though the account i have been using is marked as administrator it is not getting admin rights. So how do i elevate the privleges to get admin rights using a different account other than admin? Normally we do not enable the admin account. We just use the account that is created when you install win7.
Re: Continue batch after UAC disable
As I said microsoft made the UAC to prevent any un authorized actions that happen in the background to act without the user permissions so the only way is using the Administrator account that u activated or disabling the uac by ur self loking for a batch to trick the uac "IMPOSIBLE" and the only other way is "exploits".
Re: Continue batch after UAC disable
Okay thanks everyone I will just resolve to having to turn off uac by hand. Not a big deal but thanks for all the info. I should be able to use it in other areas.