Page 4 of 5
Posted: 2009-10-01, 07:49 UTC
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
Posted: 2009-10-01, 08:23 UTC
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.
Posted: 2009-11-04, 12:50 UTC
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?
Posted: 2009-11-04, 19:55 UTC
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.
Posted: 2009-11-06, 14:56 UTC
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)
Posted: 2009-11-06, 15:25 UTC
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.
Posted: 2009-11-29, 05:26 UTC
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
Posted: 2009-11-29, 05:38 UTC
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.
Posted: 2009-12-15, 17:01 UTC
by cheming
Sudo.exe doesn't know %COMMANDER_PATH%

Posted: 2009-12-16, 05:58 UTC
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.
Posted: 2009-12-16, 15:14 UTC
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.
Posted: 2009-12-16, 17:53 UTC
by tosbsas
hm - decode will not work (:-((
Posted: 2009-12-16, 19:06 UTC
by Horst.Epp
tosbsas wrote:hm - decode will not work (:-((
Works perfectly here
Posted: 2009-12-16, 21:12 UTC
by tosbsas
win7 , tc runs as admin
Posted: 2009-12-17, 03:41 UTC
by MVV
tosbsas wrote:hm - decode will not work (:-((
tosbsas wrote:win7 , tc runs as admin
What exactly you're trying to do?