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 »

MVV wrote: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.
Nice trick.
But you should add "2>nul" to your check, to avoid the error message in case of low rights:

Code: Select all

dir %SystemRoot%\temp > nul 2> nul
;) 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:But you should add "2>nul" to your check, to avoid the error message in case of low rights:
Thanks, I didn't know this thing.
User avatar
tom*de
Senior Member
Senior Member
Posts: 394
Joined: 2003-02-25, 09:21 UTC

Post by *tom*de »

Thank you MVV: sudo.exe is really a helpful tool. Is there any way to send the admin-UserID as a parameter: /USER:domain\myadmin?
Tom - #81178 - 5 User licence - Klugheit, Gerechtigkeit, Tapferkeit und Mäßigung plus Kooperation.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

tom*de wrote:Thank you MVV: sudo.exe is really a helpful tool. Is there any way to send the admin-UserID as a parameter: /USER:domain\myadmin?
You may use runas command with parameter /user for this task. Sudo needed when you want to elevate w/o entering password.
User avatar
tom*de
Senior Member
Senior Member
Posts: 394
Joined: 2003-02-25, 09:21 UTC

Post by *tom*de »

unfortunately my company-policies cause another behavior:

runas /user:dom\user "cmd.exe" works. (after entering password it starts cmd.exe as dom\user)
but this has not the same rights like
sudo.exe "cmd.exe" (after entering user and password (dom is permanent set) it starts cmd.exe as administrator)
Tom - #81178 - 5 User licence - Klugheit, Gerechtigkeit, Tapferkeit und Mäßigung plus Kooperation.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

tom*de wrote:unfortunately my company-policies cause another behavior:

runas /user:dom\user "cmd.exe" works. (after entering password it starts cmd.exe as dom\user)
but this has not the same rights like
sudo.exe "cmd.exe" (after entering user and password (dom is permanent set) it starts cmd.exe as administrator)
Sudo elevates current profile's rights. I don't know if Windows may elevate another profile. Runas launches process with another profile. I don't know how to elevate profile using runas command.
User avatar
romulous
Senior Member
Senior Member
Posts: 226
Joined: 2003-11-19, 04:10 UTC

Post by *romulous »

MVV wrote:Here is my very little tool that I use to run elevated apps:

Code: Select all

MIME-Version: 1.0
Content-Type: application/octet-stream; name="Sudo.zip"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Sudo.zip"

UEsDBBQAAgAIAHpnCTvmLmh5SAIAAAAIAAAIAAAAU3Vkby5leGXtVM9r01Ac/6Ytms22y6AFDxXf
Sg6eiqiHqjsU1miZ0dV2UPRk1r6sKWki6Qv0JEKYMMakl148efBPUDd76kGcirv4B4gHDwqC4kX0
El/y0nQTcfPgZewDXz7fX+/zvo+Xl6s3exAFgBg11wXYBIYC7I0hteTJQRIeT2zPbHLy9sxiU+ug
25a5bCltVFcMwyRoCSPLNpBmoOJCFbXNBs4lEpNioHFDvPfihPSxP7J380/6x33/k88XnAf9jM89
nytaven1jWYoSwAyF4GjvTvzo9x7iHLHOB4gAsw8CIGh4HQCq8WC8ojh9DhgZYH1hhySj1NUbxb+
A6hu5i/lHMFdQjnPQXiW8SFCiVs5q6EQBeBrkPD7juzuK+zvug9xAOF8nnXTgAqgOvnswPtAbN4Z
RgZZ6k1t8OrKKzKtXnxN4lMbpQgt0IT9RXV+Zm1ePS/YUS/l5JEtrD/yn3QQk+9ssc23ODcd9/V/
/K5PG2HtJUlSITLBFoL9zRdPeOK8uhUqAtkZ/WG/1aKYWo+J5a2iGPMeJGW+wDgOjIUMnWNVFlPU
zwQ55L0fN52ilZUhnTbCpl2TxXzLve6mY16wKOYrbpqnbgtY/c1Buf/79EoeUntK7S5iubcBW2CD
AQp0qN9A4zXPEfuXdHfkPlA/hf59j2cgdTVStsw67nRgmruMyZzZbitGQ9YMXINetKZo5JJpVTVj
WccLSy1cJ3AO5nSzg0u0TcdwRapck+SzZ3INXQeY5KpNrOtSF9dtgqVuDaolSQ7Lh9iFX1BLAQIU
ABQAAgAIAHpnCTvmLmh5SAIAAAAIAAAIAAAAAAAAAAAAIAAAAAAAAABTdWRvLmV4ZVBLBQYAAAAA
AQABADYAAABuAgAAAAA=
Looks interesting...but how exactly do you decode that into an executable O_o
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Copy/Paste it into an editor, save as: SomeFile.txt

Select SomeFile.txt in TC,
choose Decode File from TC's MainMenu.

You'll now have a Sudo.zip file that you can unpack.
*BLINK* TC9 Added WM_COPYDATA and WM_USER queries for scripting.
cheming
Member
Member
Posts: 153
Joined: 2004-05-07, 14:38 UTC
Location: China

Post by *cheming »

Sudo.exe doesn't know %COMMANDER_PATH% :-(
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

cheming wrote:Sudo.exe doesn't know %COMMANDER_PATH% :-(
How do you use it? If you use it from TC, let TC expand %COMMANDER_PATH%. E.g. buttonbar button for starting TC elevated:
Command: %COMMANDER_PATH%\Sudo.exe %COMMANDER_PATH%\TOTALCMD.exe /N
This command will start Sudo.exe (if it is in TC dir) and pass to it expanded path to program and parameter /N which will be then passed to started elevated TC instance. You may play with quotes around path if it (or envvar) contains spaces.
cheming
Member
Member
Posts: 153
Joined: 2004-05-07, 14:38 UTC
Location: China

Post by *cheming »

Thanks! It works now.

But I found it didn't work if I defined a use cmd em_Sudo and used it in a button.
tosbsas
Senior Member
Senior Member
Posts: 428
Joined: 2003-12-19, 13:12 UTC
Location: Lima, Perú
Contact:

Post by *tosbsas »

hm - decode will not work (:-((
A New Generation transformed by the Power of God
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6511
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

tosbsas wrote:hm - decode will not work (:-((
Works perfectly here
tosbsas
Senior Member
Senior Member
Posts: 428
Joined: 2003-12-19, 13:12 UTC
Location: Lima, Perú
Contact:

Post by *tosbsas »

win7 , tc runs as admin
A New Generation transformed by the Power of God
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

tosbsas wrote:hm - decode will not work (:-((
tosbsas wrote:win7 , tc runs as admin
What exactly you're trying to do?
Post Reply