How to? Launching TCC -- avoiding UAC dialog

#1
I don't want to shut off UAC on this Win 7 machine entirely -- but I'm tempted even though it's not a very good idea.

I'm an admin on the box, but I always always get the do-you-want-to-run-this-program query if I attempt to run TCC "elevated."

Is there some way to launch TCC "elevated" and without that dialog appearing?
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,599
46
Albuquerque, NM
prospero.unm.edu
#3
Likes: mikea
#4
Yes, it is possible to do this. Sorry, I don't have time to write up detailed instructions just now, but here's a relevant web site:

http://www.techrepublic.com/blog/wi...c-restricted-programs-without-the-uac-prompt/

Executive summary: Create a Task Scheduler job which runs TCC as admin, then create a desktop shortcut which starts that job.
The task:

General: give it a name (e.g., "TCC"); check "Run with highest privileges"
Triggers: none
Actions: start a program (e.g., "g:\tc15\tcc.exe /q")
Conditions: none
Settings: check "Allow task to be run on demand"​

The shortcut: use the name you gave to the task.

c:\windows\system32\schtasks.exe /run /tn TCC​

This causes a brief but unsightly extra console for schtasks.exe. I got around that by using a copy of schtasks.exe which had been changed from a console app to a windows app with Microsoft's EDITBIN.EXE (which comes with VC and, I suppose, other development products)
 
Likes: mikea
#5
Right Click on the Take Command shortcut, and select Properties.
Click Advanced.
Put a check mark in "Run as administrator".
Click Ok to dismiss the Advanced Options dialog, then click Ok to dismiss the Take Command Properties dialog.
Had that part covered. The issue is ensuring that the UAC confirmation doesn't appear every time.
 
#6
Thanks kindly to Charles and Vince w.r.t. the task-scheduler solution. In all the times I've used that app I never knew about this way of using it. The brief/unsightly appearance of a console window is only barely noticeable. The only drawback I see is that for some reason, when the TCC window has opened, Windows sends the focus somewhere else. I have to click the TCC window to get the focus back. Not a big deal or a deal-breaker. For all I know, there's some window-related command internal to TCC that will change the focus and if so I could maybe put it into the TCSTART script. I'll hunt around in the online help for that.

Thanks again.
 
#7
I don't want to shut off UAC on this Win 7 machine entirely -- but I'm tempted even though it's not a very good idea.

I'm an admin on the box, but I always always get the do-you-want-to-run-this-program query if I attempt to run TCC "elevated."

Is there some way to launch TCC "elevated" and without that dialog appearing?
Just change your name to Bill Gates...

[On the focus question]
Check the ACTIVATE and WINDOW commands.
 
#8
> change your name to Bill Gates...

Huh. I'll look into that.

Ok...tried putting

if %_elevated == 1 activate "%_wintitle" TOP

at the very end of TCSTART. That didn't work. Tried TOPMOST instead (which isn't desirable, but let's see if it works...nope, didn't work). With the WINDOW command, per the online help TOP and TOPMOST are used only in tab windows — presumably that means within TCMD — and I'm just running TCC by itself. Hmm. Maybe the Task Scheduler itself has some option pertaining to this.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,599
46
Albuquerque, NM
prospero.unm.edu
#9
Ok...tried putting

if %_elevated == 1 activate "%_wintitle" TOP

at the very end of TCSTART. That didn't work. Tried TOPMOST instead (which isn't desirable, but let's see if it works...nope, didn't work). With the WINDOW command, per the online help TOP and TOPMOST are used only in tab windows — presumably that means within TCMD — and I'm just running TCC by itself. Hmm. Maybe the Task Scheduler itself has some option pertaining to this.
I suspect that this would be pretty easy to add as a plugin command. 4CONSOLE seems like the obvious plugin for it.... Vince?
 
#10
Thanks kindly to Charles and Vince w.r.t. the task-scheduler solution. In all the times I've used that app I never knew about this way of using it. The brief/unsightly appearance of a console window is only barely noticeable. The only drawback I see is that for some reason, when the TCC window has opened, Windows sends the focus somewhere else. I have to click the TCC window to get the focus back. Not a big deal or a deal-breaker. For all I know, there's some window-related command internal to TCC that will change the focus and if so I could maybe put it into the TCSTART script. I'll hunt around in the online help for that.

Thanks again.
I forgot about that focus thing. I took care of it like this.
Code:
IFF %_ELEVATED == 1 THEN
    CLICK /L %@EVAL[80 + %@WORD[1,%@WINPOS[%_WINTITLE]]] %@EVAL[20 + %@WORD[0,%@WINPOS[%_WINTITLE]]]
ENDIFF
CLICK is in my SYSUTILS plugin. A quick test shows that this also works.
Code:
    DELAY /M 100
    ACTIVATE "%_WINTITLE"
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,599
46
Albuquerque, NM
prospero.unm.edu
#12
[See my recent post.] It's a little odd that CLICK works without a delay while ACTIVATE requires a delay.
Anyway, what did you have in mind, Charles?
I was thinking of a command to set the focus to the current TCC window, or maybe to a window specified on the command line. (But "the current TCC window" is itself a pretty slippery concept: it might mean the console window, or the Take Command main window... or the Console2 window, or the ConEmu window....)
 
#13
Regarding:
Code:
DELAY /M 100
ACTIVATE "%_WINTITLE"
Without the delay + activate command: the console window opens. Its border is a color that means: it doesn't have the focus. The cursor is not blinking at the command line. The task's icon in the taskbar is blinking, indicating "need attention."

With the activate command: the console window opens. Its border is again a color that means it doesn't have the focus. The task's item in the taskbar is again blinking ("need attention"). This time the cursor does appear at the command prompt and is blinking. But I still have to click the TCC window to bring the focus back (or, I can cycle to it via the task switcher).

Ah, the WWW (wacky world of Windows). :-|
 
#14
Regarding:
Code:
DELAY /M 100
ACTIVATE "%_WINTITLE"
Without the delay + activate command: the console window opens. Its border is a color that means: it doesn't have the focus. The cursor is not blinking at the command line. The task's icon in the taskbar is blinking, indicating "need attention."

With the activate command: the console window opens. Its border is again a color that means it doesn't have the focus. The task's item in the taskbar is again blinking ("need attention"). This time the cursor does appear at the command prompt and is blinking. But I still have to click the TCC window to bring the focus back (or, I can cycle to it via the task switcher).

Ah, the WWW (wacky world of Windows). :-|
I have never been annoyed by something stealing focus and I have always been annoyed by the Windows foreground lock feature.

I tried to reproduce your focus failure problem and couldn't. Quite possibly this is because I had applied a common tweak.

In "HKEY_CURRENT_USER\Control Panel\Desktop", set "ForegroundLockTimeout" to (REG_DWORD) 0.

According to TechNet, ForegroundLockTimeout "specifies the time [in milliseconds], following user input, during which the system keeps applications from moving into the foreground".

I suspect changing this value requires at least a logout/login.
 
Last edited:
#15
I have never been annoyed by something stealing focus and I have always been annoyed by the Windows foreground lock feature.

I tried to reproduce your focus failure problem and couldn't. Quite possibly this is because I had applied a common tweak.

In "HKEY_CURRENT_USER\Control Panel\Desktop", set "ForegroundLockTimeout" to (REG_DWORD) 0.

According to TechNet, ForegroundLockTimeout "specifies the time [in milliseconds], following user input, during which the system keeps applications from moving into the foreground".

I suspect changing this value requires at least a logout/login.
Can give that a try. On this system at the moment the value data is decimal 200000 (hex 30d40). So...change decimal value simply to 0?