Marco
Marco

Reputation: 187

Batch files/Windows 7 - Open UAC prompt minimized on purpose

There are many users struggling with UAC prompts opening in background instead of foreground. Well, I want to do exactly the opposite, ie having the UAC prompt flash on the taskbar and waiting for my attention instead of dimming my whole screen and messing my workflow.

Here's my setup: I'm working on a Win7 x64 machine, and I placed this link in my Startup folder:

C:\CLUs\chp.exe "apps.bat"

chp.exe is an utility that loads batch files without showing the command prompt.
apps.bat calls several unelevated programs (easier to manage apps in this way rather than putting a bunch of links in Startup). The last line of such bat is

elevate chp "elevapps.bat"

elevate.exe is an utility that, as the name says, elevates whatever is called with issuing an UAC prompt. And, clearly, elevapps.bat contains another bunch of programs that require admin rights to start properly.

Now, for a number of reasons I'd like the UAC prompt to start minimized/in background. Ie, once I've logged in Windows, all I want to see is the taskbar containing the flashing icon of the UAC, but no dimmed screen.

Is this possible with batch files? All I know is that UAC "smartly" detects whether it is stealing focus or not and (doesn't) show up accordingly. And clearly during the startup there's nothing to steal focus from, so looks like I'm having no luck. However it also seems that badly coded software (namely not assigning HWNDs somewhere, see here and here) precisely produces this effect. Is there a way to reproduce this "bug" (I'd call it a feature, in my case) with some code in a batch file? Also using a third party utility would be fine, however I'm not a programmer.

Upvotes: 0

Views: 881

Answers (1)

Marco
Marco

Reputation: 187

I solved the problem by using winapiexec.exe, an utility that allows (as per site) to run WinAPI functions through command line parameters.

winapiexec shell32.dll@ShellExecuteW NULL "runas" "chp" "elevapps.bat" NULL 7

Upvotes: 1

Related Questions