TC cmd vs Windows cmd

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

TC cmd vs Windows cmd

Post by *sollertis »

Hi!

I've noticed there's a difference between running cmd (as well as some scripts) from Total Commander and from windows start menu and/or windows run prompt.

For example some scripts executed from Total Commander (or from cmd shell spawned from within Total Commander) do not work. Unfortunately it is not possible for me to post the script here, but we had problems running shell commands from a vbs script if it was run from Total Commander (objShell.run). It worked using Windows Explorer or executing the script from command prompt spawned from windows.

I noticed something like that in the past on x64 server machines, where I remember having problems running some applications.

What exactly is the difference?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If you're using 32-bit TC on 64-bit Windows, you may have problems with some 64-bit shell extensions.

Simplest thing: execute dispkart from TC and from command prompt started from Explorer, it doesn't work from TC because diskpart is 64-bit tool only and placed in 64-bit System32 folder while consoles from TC use 32-bit SysWOW64 redirected as System32 so can't find that file (but you still able to execute the tool if you change current dir to %SystemRoot%\Sysnative folder).

If you have some extensions you may need to install them in 32-bit environment too, or start them from TC via some 64-bit proxy launcher (you may try this one - it is interesting if it will work for you).
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3897
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Post by *sqa_wizard »

As MVV already stated: The system directories are different for a 32-Bit and a 64-bit program on a 64-bit windows.

See Sticky Windows x64: Explorer vs TC: Content of System32 different for details.

Starting the script from a TC 64-bit should have the same results as Windows explorer though.
#5767 Personal license
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

The x64 thing was in the past, we were using x64 tc back then. I just mentioned that, because I have a feeling it might be related.

The actual problem is with runnig scripts on x86 win7, using x86 version of tc. So, you can as well forget about the x64 problems. Sorry to bring you off focus!
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

sollertis, how do you execute scripts from TC? Do you specify full command line including scripting tool or just script name/path?
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

2 ways:
  • Double clicking the script
  • Opening cmd from within Total Commander (from the input box on the bottom of the tc window) and running the script from the shell (e.g.: cscript script.wsf)
Both ways the same problem. If double-clicking the script from within Windows explorer or if cmd is run from the run prompt or start menu, the script works as expected.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Please try to change dir to %SystemRoot%\System32 (cd /d %SystemRoot%\System32) and execute cscript "X:\Full\Path\To\script.wsf" from console, maybe there is a problem with working directory...
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

Wow, cool! That worked! The exact steps taken:
  1. Changed dir to %SystemRoot%\System32 (in TC)
  2. Run cmd from within TC
  3. Executed the script: x:\full\path\to\script.wsf
Doing some more tests I noticed that this works from %temp% as well. But why does it not work from the script's folder? :shock:

The user I was testing with has admin rights (wanted to be sure to prevent rights issues during testing).
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Don't know why it doesn't work, maybe some files in that folder cause loading of false libraries?

Anyway, you can create buttonbar buttons for starting script files, just specify %SystemRoot%\System32 as working directory and cscript "X:\Full\Path\To\script.wsf" as command.

Or create batch file that will set dir to %SystemRoot%\System32 and then execute script passed as parameter, e.g.:

Code: Select all

@echo off
cd /d %SystemRoot%\System32
start "" cscript %1
And use it to start your scripts (e.g. you can use internal associations to run scripts with this batch automatically).

Or you can use single command w/o batch file in a button:

Code: Select all

cmd /c "start "" /D"%TEMP%" cscript "X:\Full\Path\To\script.wsf""
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

Thanks for the suggested method of exectuion. The last is the most appropriate for our situation and it works well!

I've also done some analysis and found out that if the script is run directly from the folder where it resides, an additional dll is loaded (which is not loaded if I run the script from e.g. %temp%), namely apphelp.dll.

Since apphelp.dll is Application Compatibility Client Library it makes me believe that cmd.exe run from the script's folder is executed in compatibility mode. Not sure though. Any ideas how I could prevent apphelp.dll from loading, so I could test?

EDIT: TC is run with compatibility mode disabled.
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

Analyzing totalcmd.exe shows that apphelp.dll is a total commander dependency (shell32.dll -> apphelp.dll).
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

sollertis, it doesn't describe why that DLL is loaded for child process...

BTW there are a lot of stupid compatibility fixes in default Microsoft compatibility database... E.g. they ask for elevation when you start any executable with patch word in its name, dumb! You can use their Application Compatibility Toolkit to view and modify compatibility databases but I think it will be much easier to leave it as is and use discovered way that works by default. :)
sollertis
Junior Member
Junior Member
Posts: 7
Joined: 2013-01-01, 10:09 UTC

Post by *sollertis »

it doesn't describe why that DLL is loaded for child process...
Correct. cmd.exe has the same dependency.
BTW there are a lot of stupid compatibility fixes in default Microsoft compatibility database... E.g. they ask for elevation when you start any executable with patch word in its name, dumb! You can use their Application Compatibility Toolkit to view and modify compatibility databases but I think it will be much easier to leave it as is and use discovered way that works by default. Smile
Totaly agree. Many thanks for your help!!!
Post Reply