Optional run as administrator in button bar

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Axel
Junior Member
Junior Member
Posts: 40
Joined: 2004-03-03, 12:29 UTC

Post by *Axel »

j wrote:I created a NTFS link [face=courier]TOTALCMD_ADMIN.EXE[/face] to [face=courier]TOTALCMD.EXE[/face] and set its properties to "Run this program as Administrator" - under Windows 7 this has the nice advantage that the "Admin TC" gets an extra slot in the taskbar and a little "shield" as overlay.
Hi j.

I'm also using Windows 7 (RTM) but I wont get such an overlay in my taskbar.
Additionally I can't find a way to activate such a behaviour.

Could you give me a hint how to do this?
Would you maybe also have a screenshot to ensure me not thinking in a wrong way? :)

Regards,
Axel
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Axel wrote:I'm also using Windows 7 (RTM) but I wont get such an overlay in my taskbar.
Additionally I can't find a way to activate such a behaviour.

Could you give me a hint how to do this?
Would you maybe also have a screenshot to ensure me not thinking in a wrong way? :)
It is more easier to create a link (or a button on buttonbar) to my little program that starts anything with admin rights. Just create a link for command:

Code: Select all

sudo.exe [path_to_TC]TOTALCMD.EXE [params]
You may find my tool here.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

2MVV,

Is there a way to have your program automatically pick the admin account on startup?
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Boofo wrote:2MVV,

Is there a way to have your program automatically pick the admin account on startup?
Maybe I don't understand your question right. My tool just allows you to be asked for elevation when started from anywhere, as if you choose Run as Admin from context menu. If you start it from elevated account, it just executes passed command line.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

2MVV,

I'm using XP Pro SP3 and it bring up a box that have my account and the admin account. My account is ticked automatically. I have to tick the admin account and enter the password and then it will start the program in Admin mode.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Boofo wrote:2MVV,

I'm using XP Pro SP3 and it bring up a box that have my account and the admin account. My account is ticked automatically. I have to tick the admin account and enter the password and then it will start the program in Admin mode.
Sudo just calls ShellExecute with verb "runas", the rest does operating system. In Vista/7 user shouldn't choose profile and type in a password, he just should press Yes in UAC dialog.
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

It doesn't work like that in XP. Can I run it the same way I would runas with the admin and password in the command line?
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Boofo wrote:It doesn't work like that in XP. Can I run it the same way I would runas with the admin and password in the command line?
No. Use runas for this task. :)
User avatar
Boofo
Power Member
Power Member
Posts: 1431
Joined: 2003-02-11, 00:29 UTC
Location: Des Moines, IA (USA)
Contact:

Post by *Boofo »

Ok, Thanks.
chmod a+x /bin/laden -- Allows anyone the permission to execute /bin/laden

How do I un-overwrite all my data?

User of Total Commander
#60471 Single user license
Axel
Junior Member
Junior Member
Posts: 40
Joined: 2004-03-03, 12:29 UTC

Post by *Axel »

MVV wrote:It is more easier to create a link (or a button on buttonbar) to my little program that starts anything with admin rights. Just create a link for command:

Code: Select all

sudo.exe [path_to_TC]TOTALCMD.EXE [params]
You may find my tool here.
Right, this is easier, but then the '%__COMPAT_LAYER%'-mechanism does not work any more:

Code: Select all

[Colors] 
RedirectSection=colors_%__COMPAT_LAYER%.ini
Can I somehow else determine, that I'm in 'admin-mode' to redirect the section?


Additionally I'm still wondering about my missing overlays:
I'm also using Windows 7 (RTM) but I wont get such an overlay in my taskbar.
Additionally I can't find a way to activate such a behaviour.
Or does maybe nobody have such overlays?
Maybe it was a feature of the RC of Windows 7?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I don't know any easy way to determine if program started elevated. When I created some bat-files that should be run elevated, I'd added following check in the beginning:

Code: Select all

@echo off
dir c:\windows\temp>nul
if not errorlevel 1 goto elevated
echo Please run this with administrator rights.
pause
goto exit
:elevated
rem Commands to be executed elevated
I use fact that folder C:\Windows\Temp bay be browsed only by elevated process (it may be any such folder).
So, I think it is possible to start TC from bat-file and set some envvar to one value if elevated and to other otherwise.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Should probably be %windir%\TEMP instead of C:\Windows\Temp no?
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Balderstrom wrote:Should probably be %windir%\TEMP instead of C:\Windows\Temp no?
Maybe. It doesn't matter. You've got the idea, the rest is not so important.
The idea is that dir command returns error when lists user-restricted directory, so we can use it for our aims. :)
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Yeah, I used something similiar to determine whether a RamDisk "folder" was mounted or not :-)

Code: Select all

SET create=mkdir
IF "%tmpDIR:~-5,4%"==".mnt" SET create=pfm mount
PUSHD %tmpDIR% 1>NUL 2>&1
IF %ERRORLEVEL%==1 (
	%create% %tmpDIR%
) ELSE (
	POPD
)
User avatar
Stefan2
Power Member
Power Member
Posts: 4159
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Post by *Stefan2 »

Thank you MVV, this is nifty. I take it into my tool box.


Code: Select all

TOTALCMD#BAR#DATA
%Commander_PATH%\Tool\CMDs\Sudo.exe
?%P%N
%Commander_PATH%\TOTALCMD.EXE,10
Sudo run App As Admin


-1



---

To launch an DOS-Box with Admin-rights i launch this batch from an button:
RunAsADMIN.cmd

Code: Select all

@Echo off && Title Launch console as ADMIN && COLOR 1F
RUNAS /USER:Administrator "cmd /T:4F /K TITLE ADMIN RIGHTS" && "/K /F:ON /E:ON"

or more simple:
@ECHO OFF
runas /user:administrator cmd


To run TC with Admin-rights start this batch from an button:
RunTCAsADMIN.cmd

Code: Select all

@Echo off && Title Launch console as ADMIN && COLOR 1F
RUNAS /USER:Administrator "%Commander_PATH%\TOTALCMD.EXE"
General use:
runas /user:Administrator "yourTool"

F.ex. to run WinExplorer with admin rights
start iExplorer with admin rights first and type C: into the address bar:
runas /user:Administrator "%ProgramFiles%\Internet Explorer\iexplore"



To launch the pointed/selected program as admin:
RunPointedAsADMIN.cmd

Code: Select all

REM RunPointedAsADMIN.cmd
@Echo off && Title Launch console as ADMIN && COLOR 1F
RUNAS /USER:Administrator "%1"


GOTO EOF
----8<---------8<----- TC button ----8<---------8<-----
TOTALCMD#BAR#DATA
%Commander_PATH%\TOOL\CMDs\RunPointedAsADMIN.cmd
%P%N
%Commander_PATH%\TOTALCMD.EXE
RunPointedAsADMIN run App as Admin


-1
----8<---------8<---------8<---------8<---------8<-----
:EOF


To launch a DOS-Box with System-rights:
RunAsSys.cmd

Code: Select all

@Echo off && Title Launch console as ADMIN && COLOR 1F
RUNAS /USER:Administrator  "SysRun.exe cmd.exe /T:4F /K TITLE System RIGHTS"
REM RUNAS /USER:Administrator  "SysRun yourTool"
REM benötigt SysRun 1.3 von Brian Friesen Copyright © 2003 
REM http://users.csc.calpoly.edu/~bfriesen/software/

Note:
to run cmd box as system there are also
PowerPrompt from http://GrubleTrang.com
supershell from http://www.p-nand-q.com/download/supershell.html
(must be launched with admin rights)

You will always be asked for the Admin password! Works for me on XP.

Post 123
Post Reply