UAC and batch files

W

Wildcat

I am trying to run a batch file at startup that turns UAC off. It runs fine
if UAC is already off but access is denied if it is not already off. This
was not the intention of the .bat file. I am using Home Premium and it
seems that Windows Defender turns UAC on when it is run and then I have to
turn it off manually and re-boot. Too much time. Anyone know how to stop
the access denied? I tried permissions on the USERS folder to no avail.
 
J

Julian

Use the Task Scheduler to run your batch file - you will be able to give it
elevated permissions there and there will be no UAC prompt: you could use
e.g. a delay of 30s from log-on as the trigger. This is the only way I know
of running apps that require elevated privileges without getting the UAC
prompt at run time, and I use it successfully to start a couple of
applications that Defender otherwise blocks (of course the "offending" apps
are also removed from the Startup group otherwise there would still be the
Defender nag from the systray/"Notification area"

Hope that helps...
 
W

Wildcat

Thanks, it sort of helped but it still requires another boot after running
the batch file [which contains C:\Windows\System32\cmd.exe /k
%windir%\System32\reg.exe ADD
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA
/t REG_DWORD /d 0 /f ] in order to actually turn UAC off. I tried a
second batch file run upon logon to reboot (shutdown -r -t 0) but I got
into a perpetual reboot situation which required an Acronis restore to get
out of. Any idea how to get the second boot only if UAC is turned on?
 
J

Julian

Whoa! Didn't realise that you were turning off UAC by poking the
registry...! And I don't know whether turning UAC on or off usually requires
a reboot - though I doubt it... but maybe.

If there is no command line interface that supports UAC control (Don't Ask
Me - I Dunno) you could perhaps make your "reboot" batch file conditional on
the registry value - so that after a restart after UAC OFF it does not
restart the system again... but again as to how - DAM-ID (sorry)

Didn't know that Defender re-enabled UAC... can you confirm that? I wonder
if you have Real Time Protection on and "System Configuration (Settings)"
checked - that *might* look on UAC being off as "unexpected and undesirable"
and undo it...

However, after much head scratching I am obliged to ask Why? Why do you need
to turn UAC off? It is worth keeping - a slight annoyance perhaps but if you
run an Administrator account (instead of limited user) all you have to do is
click to OK actions - rather than enter the admin password... it's not so
bad... (I can't believe I just said that, but I did)

--
Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com
Wildcat said:
Thanks, it sort of helped but it still requires another boot after running
the batch file [which contains C:\Windows\System32\cmd.exe /k
%windir%\System32\reg.exe ADD
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v
EnableLUA /t REG_DWORD /d 0 /f ] in order to actually turn UAC off.
I tried a second batch file run upon logon to reboot (shutdown -r -t 0)
but I got into a perpetual reboot situation which required an Acronis
restore to get out of. Any idea how to get the second boot only if UAC is
turned on?







Julian said:
Use the Task Scheduler to run your batch file - you will be able to give
it elevated permissions there and there will be no UAC prompt: you could
use e.g. a delay of 30s from log-on as the trigger. This is the only way
I know of running apps that require elevated privileges without getting
the UAC prompt at run time, and I use it successfully to start a couple
of applications that Defender otherwise blocks (of course the "offending"
apps are also removed from the Startup group otherwise there would still
be the Defender nag from the systray/"Notification area"

Hope that helps...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top