The following starts PowerShell 1.0 but does not set the start path. Anybody knows why? Setting it to a fixed one, like "C:\Windows" works fine.
I tried the path with and without quotes, no luck. Also, this version of PS does not seem to support -WorkingDirectory command-line parameter. Is there another?
For me, the following button starts in the current TC dir without the need for any tricks.
Using the button context menu, I can also start it as Administrator.
The current directory set via SetCurrentDirectory is not passed to programs run as administrator. This is true for all programs, not just for powershell.
TOTALCMD#BAR#DATA
*C:\Program Files\PowerShell\7\pwsh.exe -NoExit
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
PowerShell as admin in the current active pane path
cd $pwd
0
-1
TOTALCMD#BAR#DATA
*C:\Program Files\PowerShell\7\pwsh.exe -NoExit
-c cd $pwd
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
PowerShell as admin in the current active pane path
-1
Contex-menu action button example to run As Admin in $pwd:
TOTALCMD#BAR#DATA
C:\Program Files\PowerShell\7\pwsh.exe -NoExit
C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
PowerShell as admin in the current active pane path
cd $pwd
0
-1
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 16
ghisler(Author) wrote: 2025-05-25, 10:31 UTC
The current directory set via SetCurrentDirectory is not passed to programs run as administrator. This is true for all programs, not just for powershell.
And why does my button above works when I select "As Administrator" from the Button context menu ?
Also, when TC runs already enhanced, the button starts PowerShell as Administrator in the correct path.
Windows 11 Home, Version 24H2 (OS Build 26100.4351) TC 11.55 RC6 x64 / x86
Everything 1.5.0.1395a (x64), Everything Toolbar 1.5.5.0, Listary Pro 6.3.2.88
QAP 11.9.0.3 x64
Dalai wrote: 2025-05-25, 09:59 UTC
To start something with the current path as working directory just leave the Start Path empty.
Yup. Nice, except if you want to start it "as admin" and you have put a * in front of the executable. Then you've lost...
ghisler(Author) wrote: 2025-05-25, 10:31 UTC
The current directory set via SetCurrentDirectory is not passed to programs run as administrator. This is true for all programs, not just for powershell.
I found this not to be true, at least for my Windows 11 system. The current folder is set to c:\windows\system32 when running programs as administrator if the program is located in c:\windows or any of its subfolders. For programs outside c:\windows, the current folder is not changed. For example, the current folder is not set to c:\windows\system32 when running "C:\Program Files\IrfanView\i_view64.exe" as administrator. Nor when copying "cmd.exe" and "en-US\cmd.exe.mui" to a folder outside the windows folder and running cmd.exe located in that folder as administrator.
Edit: Also tested on Windows Vista where it works the same. It seems the behavior was always bound to program within the windows folder.