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:
@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:
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.
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.
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.