Run program from Button bar

English support forum

Moderators: Stefan2, white, sheep, Hacker

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Run program from Button bar

Post by *d-sphinx » 2019-07-29, 15:02 UTC

Hi everyone!

I am a very old TC user (since it was Windows Commander, thus i still launch it via Ctrl+Alt+W combo because i get used to back in the day).
And I registered here for the first time because I got stuck with a strange behavior...

My .cmd batch file, and program that it starts, act differently when they are launched from Button bar and when launched directly by hitting Enter on it in a folder navigation window. When I launch it from button bar click i have an error, when i launch .cmd directly - it's ok. I've checked it several times after 2 reboots... Why? Are there any issues with running file different way? :shock:

I use Windows 7 and logged in with admin rights, TC ver. 8.52a (checked with 9.12 - same problem).
Please nudge me in a right direction)

p.s. this is unlikely due to a wrong startup folder, i change dir with cd command at the 1st line of my .cmd file: cd c:\my_path\...

Thank you!

User avatar
Dalai
Power Member
Power Member
Posts: 6624
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Run program from Button bar

Post by *Dalai » 2019-07-29, 15:32 UTC

Most likely no one can help you unless you tell us which error you're getting when launching from the button bar. Or, even better, copy the button and paste it here in [code] tags.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-29, 16:02 UTC

Dalai, here is the text from DEFAULT.BAR

button37=C:\Windows\System32\imageres.dll,-68
cmd37=c:\_WORK\edc_ui\start.cmd
path37=c:\_WORK\edc_ui\
menu37=start

Here is the content of start.cmd itself:

cd c:\_WORK\edc_ui
npm start

Very simple. 'npm start' launches Node.js server. The problem is that when i launch start.cmd from Button bar i get constant error output in browser. And there are no errors if i launch batch directly or via command prompt.

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-29, 16:07 UTC

I know that it sounds strange, but i'm really confused with it.

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-29, 16:10 UTC

It is possible to log into my PC via TeamViewer if it may be of help. I can grant it.

User avatar
Usher
Senior Member
Senior Member
Posts: 407
Joined: 2011-03-11, 10:11 UTC

Re: Run program from Button bar

Post by *Usher » 2019-07-29, 17:27 UTC

d-sphinx wrote:
2019-07-29, 16:02 UTC
Here is the content of start.cmd itself:
"Start" is internal command of cmd.exe. Reusing this name may be misleading. Rename your script to startnpm.cmd, startN.cmd or anything else. Just in case…
d-sphinx wrote:
2019-07-29, 16:02 UTC
cd c:\_WORK\edc_ui
Use the /D switch to change current drive in addition to changing current directory for a drive. Suppose you want to click your button when browsing files on pendrive or DVD…

Code: Select all

cd /d c:\_WORK\edc_ui
Regards from Poland
Andrzej P. Wozniak

User avatar
Stefan2
Power Member
Power Member
Posts: 2549
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Run program from Button bar

Post by *Stefan2 » 2019-07-29, 17:53 UTC

Hi and welcome d-sphinx
d-sphinx wrote:
2019-07-29, 15:02 UTC
p.s. this is unlikely due to a wrong startup folder, i change dir with cd command at the 1st line of my .cmd file: cd c:\my_path\...
d-sphinx wrote:
2019-07-29, 16:02 UTC
Dalai, here is the text from DEFAULT.BAR

button37=C:\Windows\System32\imageres.dll,-68
cmd37=c:\_WORK\edc_ui\start.cmd
path37=c:\_WORK\edc_ui\
menu37=start

Here is the content of start.cmd itself:

cd c:\_WORK\edc_ui
npm start

Please right click at the button in the button bar and chose COPY,...... paste that here in.
Also use Ctrl+C on the error dialog (or Ctrl-A + Ctrl-C on the error output in browser) and post that also here.


There is no problem in naming a batch START.cmd for to launch that batch (ok, may be depend on the used OS),
but not using well know names is definitive a good idea,
for example the need to use the internal command START in the directory with that batch in may not work as expected.

But probably you have space in your real path and you didn't use quotes there.
So please post your real command details and not modified examples only.




Also you can modify your start.cmd to:

Code: Select all

@ECHO OFF
cd "c:\_WORK\edc_ui"
npm start
PAUSE
and check there the error message and post that here.





 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-30, 13:28 UTC

Please right click at the button in the button bar and chose COPY,...... paste that here in.
Ok, here it is:

Code: Select all

TOTALCMD#BAR#DATA
c:\_WORK\edc_ui\startNPM.cmd

C:\Windows\System32\imageres.dll,-68
start
c:\_WORK\edc_ui\

-1
I modified my batch script as you said, also changed its name to startNPM.cmd

Here is the script console output after running by hitting Enter on it in navigation window:
Image: https://i.imgur.com/RQ1PaZo.png

Here is the output after clicking on a Button bar:
Image: https://i.imgur.com/M5JhSJa.png

They are the same (except the height of drive letter C: - don't know why).
But - the result is different! Running directly starts server normally:
Image: https://i.imgur.com/K87Onyu.png

Running via Button bar's shortcut:
Image: https://i.imgur.com/FNt42LJ.png

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-30, 13:32 UTC

One little guess: do running programs from toolbar affect environment variables? Like node_env=production
If yes it may be the reason.

User avatar
Stefan2
Power Member
Power Member
Posts: 2549
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Run program from Button bar

Post by *Stefan2 » 2019-07-30, 14:06 UTC

Thanks for the detail information.

d-sphinx wrote:
2019-07-30, 13:32 UTC
One little guess: do running programs from toolbar affect environment variables? Like node_env=production
If yes it may be the reason.

In TC start a DOS console ( menu Commands > open command prompt)
and type SET + enter
or even SET nod + enter




Please note: different users (a elevated admin f.ex. is) have different environments. Just in case...


 
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

User avatar
norfie²
Power Member
Power Member
Posts: 820
Joined: 2006-02-10, 07:27 UTC

Re: Run program from Button bar

Post by *norfie² » 2019-07-30, 14:36 UTC

Maybe it is a problem with different environments if 64-bit OS and 32-bit TCmd is used.
"War is evil, in so far as it makes more bad people than it takes away."
Immanuel Kant in "Perpetual Peace"

User avatar
Dalai
Power Member
Power Member
Posts: 6624
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Run program from Button bar

Post by *Dalai » 2019-07-30, 14:55 UTC

Get Process Explorer or Process Hacker and take a close look at the process details of the running server (one after the other).

Are you sure you use the exact same batch file that's used in the button bar? Does it have the same working directory?

Grüße
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

d-sphinx
Junior Member
Junior Member
Posts: 10
Joined: 2019-07-29, 14:27 UTC

Re: Run program from Button bar

Post by *d-sphinx » 2019-07-30, 15:32 UTC

Dalai, i'm sure that use exact same file in each scenario.

Working directory also the same, moreover i change it explicitly on the 1st line of script - just to be sure:
@ECHO OFF
cd /d "c:\_WORK\edc_ui"
cd
pause
clear
set
pause
npm start
PAUSE

As for the Process Hacker I can't see anything unusual between two runs, except minor differences in memory consumption but this is expected - cause server refuses to work with client on one run and runs on another...

Stefan2, I already checked - environment is the same for both runs.
The ONLY visual difference in console output I got so far is "c:" and "C:" in path but this is ridiculous. Anyway - the server _launches_ both ways, so path hardly to be the reason. If i had, lets say, Cyrillic C instead of Latin - it wouldn't launch at all just at the start.

User avatar
Dalai
Power Member
Power Member
Posts: 6624
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Run program from Button bar

Post by *Dalai » 2019-07-30, 16:49 UTC

d-sphinx wrote:
2019-07-30, 15:32 UTC
As for the Process Hacker I can't see anything unusual between two runs, except minor differences in memory consumption but this is expected - cause server refuses to work with client on one run and runs on another...
Did you check the process details by double-clicking on it? There you should take a look at the environment variables, the working (current) directory and elevation status (or user name).

If there's no difference, try the latest TC version (currently 9.22a) and/or TC 64-bit. If that doesn't change anything, I'm out of ideas.

Regards
Dalai
#101164 Personal licence
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

User avatar
Stefan2
Power Member
Power Member
Posts: 2549
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Run program from Button bar

Post by *Stefan2 » 2019-07-30, 18:17 UTC

d-sphinx wrote:
2019-07-30, 15:32 UTC

The ONLY visual difference in console output I got so far is "c:" and "C:" in path but this is ridiculous.

If you want to change that try one or both of these INI-Parameters

DrivesExportUpcase=
DrivesShowUpcase=

From the Help > Configuration and Switches > Ini file Settings


Total Commander 7.50 Public Beta 2

26.04.09 Added: wincmd.ini [Configuration] DrivesShowUpcase=1
shows drives with uppercase drive letters in drive bar, drive dropdown list,
current dir, tabs and to the left of the command line

26.04.09 Added: wincmd.ini [Configuration] DrivesExportUpcase=1
exports paths with uppercase drive letters in functions like Mark - Copy to clipboard with full path,
and when launching programs (current dir, program name)



Note: The location of the ini files can be seen in menu Help - About Total Commander.
If entry doesn't exists, just create them below of [Configuration]






 Find me: upper case drive letter C: .... lower case drive letter c: ...... ucase upcase drive
Inofficial FAQs || WIKI (Deu/Eng) || TC Home (What's new? // FAQ // Download // Order // Addons // Tools // Plugins)
Erst wenn der letzte Baum gefällt oder die letzte Biene verendet ist, werden die Leute verstehen warum Umweltschutz wichtig ist.

Post Reply