When run %ComSpec% /c, window is not close automatically?
Moderators: Hacker, petermad, Stefan2, white
When run %ComSpec% /c, window is not close automatically?
When run:
%ComSpec% /c "C:\Program Files\TotalCmd\TOTALCMD64.EXE"
secondary session after execution is not Closed
I have to close TOTALCMD64.EXE to hit.
why?
%ComSpec% /c "C:\Program Files\TotalCmd\TOTALCMD64.EXE"
secondary session after execution is not Closed
I have to close TOTALCMD64.EXE to hit.
why?
Re: %ComSpec% /c not close
[mod="Hacker"]Moved to the English forum.[/mod]
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: %ComSpec% /c not close
Hurdet,
It's because CMD does not close as long as the invoked program is running. Try:
Roman
It's because CMD does not close as long as the invoked program is running. Try:
Code: Select all
%ComSpec% /c notepad
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Re: %ComSpec% /c not close
Hurdet wrote: 2020-03-19, 18:55 UTC When run:
%ComSpec% /c "C:\Program Files\TotalCmd\TOTALCMD64.EXE"
secondary session after execution is not Closed
I have to close TOTALCMD64.EXE to hit.
why?
If I understood you correctly, you want to execute an application via ComSpec without keeping the black DOS window open?
Try
cmd /c START "" "C:\Program Files\TotalCmd\TOTALCMD64.EXE"
Or just "C:\Program Files\TotalCmd\TOTALCMD64.EXE" alone
HTH?
Re: %ComSpec% /c not close
It is not correct.Hacker wrote: 2020-03-19, 19:15 UTC It's because CMD does not close as long as the invoked program is running. Try:Code: Select all
%ComSpec% /c notepad
"/C Carries out the command specified by the string and then terminates"
try:
%ComSpec% /c write.exe
I assume that the recent ComSpec may have particular requirements to function properly.
I assume also that this is correlate a this.
I know this but I am interested in investigating the specific problem because I suspect it may also have other repercussions.Stefan2 wrote: 2020-03-19, 19:32 UTC If I understood you correctly, you want to execute an application via ComSpec without keeping the black DOS window open?
ty, excuse me.
Re: %ComSpec% /c not close
2Hurdet
write.exe is only a wrapper that calls wordpad.exe and then terminates itself - see Windows Task Manager. That's why %ComSpec% /c write.exe works how you expect it, while %ComSpec% /c notepad.exe does not.
And, BTW, something like "%ComSpec% /c totalcmd.exe" can be classified as "useless use of CMD" (quote in the style of "useless use of cat" or "useless use of ls" known from Linux).
Regards
Dalai
write.exe is only a wrapper that calls wordpad.exe and then terminates itself - see Windows Task Manager. That's why %ComSpec% /c write.exe works how you expect it, while %ComSpec% /c notepad.exe does not.
And, BTW, something like "%ComSpec% /c totalcmd.exe" can be classified as "useless use of CMD" (quote in the style of "useless use of cat" or "useless use of ls" known from Linux).
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: %ComSpec% /c not close
I am not full convinced, try:
%ComSpec% /c "C:\Program Files\Firefox\Firefox.exe"
%ComSpec% /c "ProcessHacker.exe"
%ComSpec% /c explorer.exe
%ComSpec% /c "c:\Program Files (x86)\Internet Explorer\iexplore.exe"
otherwise "/ C" should work only in batch dos? but it is not speciefed in command dos help.
%ComSpec% /c "C:\Program Files\Firefox\Firefox.exe"
%ComSpec% /c "ProcessHacker.exe"
%ComSpec% /c explorer.exe
%ComSpec% /c "c:\Program Files (x86)\Internet Explorer\iexplore.exe"
otherwise "/ C" should work only in batch dos? but it is not speciefed in command dos help.
Re: %ComSpec% /c not close
2Hurdet
%ComSpec% /C works as it's supposed to in every case. If it wouldn't, people would have complained about it for many years, not just in conjunction with TC. As soon as the launched process ends, %ComSpec% returns control to the user, or in case of /C it closes itself. When the launched process is a wrapper that creates another process by itself (and terminates itself after that), it closes immediately. That's just how it works and how it's supposed to work.
If you're in doubt, check for the "Parent" process in Process Hacker. If it doesn't exist anymore - e.g. with firefox.exe - the process launched by %ComSpec% terminated itself, hence /C closes the window. There are also other situations where a process tells another process to spawn a new process. That's the case for explorer.exe, which tells svchost.exe to run something like "C:\Windows\explorer.exe /factory,{ceff45ee-c862-41de-aee2-a022c81eda92} -Embedding" - complicated stuff that I don't understand (but I don't need to).
If you want to avoid the black CMD window, just call the program's EXE directly, or use %ComSpec% /C start "" "path\to\programexe" as already suggested by Stefan2.
Regards
Dalai
%ComSpec% /C works as it's supposed to in every case. If it wouldn't, people would have complained about it for many years, not just in conjunction with TC. As soon as the launched process ends, %ComSpec% returns control to the user, or in case of /C it closes itself. When the launched process is a wrapper that creates another process by itself (and terminates itself after that), it closes immediately. That's just how it works and how it's supposed to work.
If you're in doubt, check for the "Parent" process in Process Hacker. If it doesn't exist anymore - e.g. with firefox.exe - the process launched by %ComSpec% terminated itself, hence /C closes the window. There are also other situations where a process tells another process to spawn a new process. That's the case for explorer.exe, which tells svchost.exe to run something like "C:\Windows\explorer.exe /factory,{ceff45ee-c862-41de-aee2-a022c81eda92} -Embedding" - complicated stuff that I don't understand (but I don't need to).
If you want to avoid the black CMD window, just call the program's EXE directly, or use %ComSpec% /C start "" "path\to\programexe" as already suggested by Stefan2.
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: %ComSpec% /c not close
ok, you convinced me.
I try ShellExecute.
I try ShellExecute.