How to send source path to a button or usercmd start by asterisk?
Moderators: Hacker, petermad, Stefan2, white
How to send source path to a button or usercmd start by asterisk?
I added a usercmd *C:\Windows\system32\cmd.exe, but it will not set the path to the source like the unprivileged one, what should I do to send the source path as start path?
- ghisler(Author)
- Site Admin
- Posts: 50550
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: How to send source path to a button or usercmd start by asterisk?
This is a known Windows bug, shells started with admin rights always launch in c:\windows\system32
You could send "%P" as one of the parameters, and then use that to change to the correct directory, e.g. with
cd %1
You could send "%P" as one of the parameters, and then use that to change to the correct directory, e.g. with
cd %1
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: How to send source path to a button or usercmd start by asterisk?
According to this answer on StackOverflow it's a security feature:ghisler(Author) wrote: 2022-01-14, 15:35 UTCThis is a known Windows bug, shells started with admin rights always launch in c:\windows\system32
If you think about it, it makes sense as a security feature. It could help prevent some DLL dropping attacks where a user places some DLL with the same name as known Windows DLLs (like kernel32.dll or shell32.dll or similar) in the same directory as an executable file. Now instead of loading the malicious DLL, the system loads the one from a directory that is known to be safe: the Windows (or system32) directory when the executable is launched elevated (via runas verb).Microsoft added this as a security feature starting in Windows 8. Whenever cmd.exe detects it's running elevated, it ignores its launch parameters and always starts in %SystemRoot%\System32. You cannot override this behavior.
But there are indications that it started in Vista:
SS64.com also mentions it:A particularly vexing problem — which the prologue solves — is that in Vista with UAC, if a .BAT file is launched "as Administrator," it doesn't start up in the folder where INSTALL.BAT resides — instead it's usually running in Windows\System32. So one of the steps in the prologue is to get back to the right startup folder.
(Though I don't agree with the "disconnected" part.)When a script is run with elevated permissions several aspects of the user environment may change: The current directory, the current TEMP folder and any mapped drives will be disconnected.
Anyway, I don't think it's a bug. If it was, MS would have fixed it within the last 14 years, wouldn't they? Yeah sure, there are other long-standing bugs in Windows like the one in wevtutil...
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Re: How to send source path to a button or usercmd start by asterisk?
I use this command to start as administrator in current directory:
Code: Select all
[em_ext_cmdelevated]
cmd=*%COMSPEC% /C
param=Start /D"%P"
menu=Command Prompt as Administrator
button=cmd.exe
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: How to send source path to a button or usercmd start by asterisk?
thanks. problem solved.petermad wrote: 2022-01-14, 18:16 UTC I use this command to start as administrator in current directory:Code: Select all
[em_ext_cmdelevated] cmd=*%COMSPEC% /C param=Start /D"%P" menu=Command Prompt as Administrator button=cmd.exe