How To Execute Cmd.exe Silently?

23

6

I use below code in Run dialog of Windows XP.

cmd /c "C://Program Files/Adobe/Adobe Photoshop CS4/Photoshop.exe"

You may replace the program path any program installed on your system. The problem is Photoshop launches up but cmd.exe window still keeps. I do not want to cmd.exe file pop up. Is it possible to launch up a program via cmd without opening a cmd.exe window? I need cmd work silently. BTW, I need this code for a program. So I need to start the program via cmd but without cmd.exe window popping up.

Further Comments

Because I will use that code in a program. Program can initiate the cmd exe. But the problem is we do not know which version of Photoshop installed. So it can be Photoshop CS4 or Photoshop CS5. Normally when you type below code in Run you get the Photoshop no matter which is installed.

photoshop

So I want to initiate the Photoshop with this method. Program will initiate cmd as Run above but something like below:

cmd /c photoshop

But it does not work. And even the cmd window appears up. I want to make the process run silently. Also we should not install any other tool. I want a solution that will work on a default Windows.

Valentina Tatya

Posted 2010-09-21T15:53:08.873

Reputation:

6Why use cmd.exe instead of just starting Photoshop directly, if you don't want CMD in the first place? – CarlF – 2010-09-21T16:02:30.837

perhaps valentina miswrote .. and wants to start it with a command, and she considers start..run..blah<ENTER> to be a command.. so could do start..run...[pathtophotopshop]<ENTER> Then skip the cmd /c, and it just starts, with no command prompt – barlop – 2010-09-21T19:08:46.177

I agree...this makes no sense. Could you clarify why you want to do it this way? – Shinrai – 2010-09-21T22:22:01.363

FYI, OP has posted a response as an answer since she doesn't have comment privileges yet – Pops – 2010-09-22T20:37:25.207

@Lord: You can always post a comment on your own question/answer. – Hello71 – 2010-09-22T22:17:27.857

@Hello, normally you'd be right, but there seems to be an account association problem going on in this case. – Pops – 2010-09-23T01:02:12.740

1CMDOW supposedly does this. – CGA – 2010-09-21T18:51:28.530

Try cmd.exe /q /c [command] – qroberts – 2010-09-21T16:06:16.913

No that won't work. You try it! Also, it'd be /q /c command if anything cmd /q /c "c:\program files\microsoft office\office11\winword.exe" Notice that the command window pops up. He doesn't want that. If you would've tried it, you would've known that!! – barlop – 2010-09-21T16:29:40.790

3No need to get upset over it. Also, the questioner is a female, not male. – qroberts – 2010-09-21T17:35:08.327

Sorry, I don't really understand what you want. You give a cmd.exe call but you say you want to use that code (which code?) in a program. What do you mean with "program can intitiate the cmd exe"? What do you mean with you want to initiate the Photoshop? As you write just typing "photoshop" does what you want. So why don't you just do this? If you write your own program, how do you run the command line you wrote? – Werner Henze – 2013-11-12T08:39:40.037

Answers

22

The problem is that the Command Prompt (cmd) cannot terminate - it is stuck up there on the screen waiting for Photoshop to terminate.

To launch Photoshop in a bat file and let the batch file continue on and terminate, use the start command, which starts a specified program or command in a separate window.

For example:

start "" "C:\Program Files\Adobe\Adobe Photoshop CS4\Photoshop.exe"

harrymc

Posted 2010-09-21T15:53:08.873

Reputation: 306 093

3isn't the start command run from a command window? in which case a command window would've popped up. I would think that once in cmd.exe, the only advantage to start, would be that it lets you choose whether you want it minimized or maximized.. but if he doesn't want it there at all.. how would it help? And if using start from cmd.exe then he may as well just type the path of the program without start. – barlop – 2010-09-21T19:05:01.473

@barlop: Without start, the script is frozen until the program terminates. With start, the script can terminate and disappear. – harrymc – 2010-09-21T20:25:43.063

out of interest, what do you mean by the script.. do you mean them doing start blah.vbs "c:....\photoshop.exe" ? and having blah.vbs (a script file) start it? – barlop – 2010-09-21T20:49:59.640

@barlop: I just meant the old and true bat file, which I assume is what the poster uses. I changed script->bat file. – harrymc – 2010-09-21T20:53:14.367

4

HSTART http://www.ntwind.com/software/utilities/hstart.html

You can do

  • start ... run
  • c:\hstart\hstart.exe /NOCONSOLE "cmd /c "c:\program files\microsoft office\office11\winword.exe""

or create an icon.

Some use it to run bat files.. (others do so from a vbs which can also run it with cmd.exe and hide the command window)..but you can use hstart.

I do echo others though, in since you are running an EXE, if you do start..run..pathofexe or make an icon for it, a command prompt won't launch. So why do you want to start it from cmd.exe ?

Also, note.. in dos and windows you use backslashes in directory paths. Forward slashes are for URLs or directory paths in unix or linux.

barlop

Posted 2010-09-21T15:53:08.873

Reputation: 18 677

1Failed to mention the program is $20 and has a pop-up nag screen every time you use it during the trial! – KidACrimson – 2019-12-20T19:49:55.743

@KidACrimson ah I hadn't used it, thanks for the info – barlop – 2019-12-20T20:25:43.037

Do you know what hstart is doing? How is it hiding the created window? – Ross Rogers – 2011-11-21T19:29:53.513

1

@RossRogers I don't know but maybe API Monitor would tell you http://www.apimonitor.com/ and also, vbscript can hide a window too. http://superuser.com/questions/62525/run-a-completly-hidden-batch-file and that mentions a program called Quiet, from this site joeware.net http://www.joeware.net/freetools/tools/quiet/index.htm which mentions that his program uses ShellExecuteEx to do it.

– barlop – 2011-11-22T03:33:32.480

3

The best option is to ask what you are trying to do. If you require the 'code' for a program, why don't you use Shell execute?

And I can't imagine what legitimate work flow would require command line to be called, which in turn would run an executable.

Devdatta Tengshe

Posted 2010-09-21T15:53:08.873

Reputation: 1 656

2

There is a tool called Quiet that you can use to accomplish this. Simply pass your .exe or .bat file to it as an argument. For this, simply create a shortcut of cmd command prompt in your desktop. Then get properties of the command prompt shortcut that you've made. Afterwards, in the "Shortcut" tab, fill in the "Target" field like this:

[pathToQuiet.exe] [pathToThe(.exe)/(.bat)file]

If you double click the shortcut, your process will be launched and you can check that through your process list, in task manager.

Note that there shouldn't be any white space in the path to both Quiet.exe and your .exe or .bat file.

Mostafa

Posted 2010-09-21T15:53:08.873

Reputation: 29

Quiet seems to run on Windows NT up to XP. Doesn't say anything about Windows 10. Do you think it might be safe to use it on Windows 10? – Henrik – 2018-04-28T22:46:52.510

@Henrik what do you mean 'safe'? It won't break it. There's no harm in trying! – barlop – 2018-04-28T23:11:27.440

@Henrik I won't do any harm, try it. – Mostafa – 2018-07-04T07:09:58.153

It doesn't work in Win10, just tried it. It does nothing. – KidACrimson – 2019-12-20T19:37:45.273

2

cmd /c "C://Program Files/Adobe/Adobe Photoshop CS4/Photoshop.exe" %*

• the [path]\name of your executable.
• all the other arguments needed by your script (%*) - Just to execute the exe in the background.

user2361573

Posted 2010-09-21T15:53:08.873

Reputation: 21

This doesn't work. It gives an error message "The system cannot find the file %*" – DavidPostill – 2015-07-08T16:44:12.560

Works without the %* part. – Jin Kwon – 2016-12-04T12:55:45.997

1

If you want to run a command and then exit the prompt immediately, you can do this...

cmd /c "C://Program Files/Adobe/Adobe Photoshop CS4/Photoshop.exe" && exit

http://www.thewindowsclub.com/command-prompt-tricks-windows (See run multiple commands sections)

user472096

Posted 2010-09-21T15:53:08.873

Reputation: 11

0

Why not use this?

cmd /c start "C://Program Files/Adobe/Adobe Photoshop CS4/Photoshop.exe exit"

Bats92

Posted 2010-09-21T15:53:08.873

Reputation: 11

1Can you explain this answer in more detail? – bwDraco – 2015-07-08T17:48:06.510

After trying everything else, only this helped. Thanks. ```#include <windows.h>

int main() { system("cmd /c start C:/WINDOWS/system32/notepad.exe"); }``` – James Koss – 2019-06-19T01:46:30.613

-2

I finally figured out a way that at least in windows 10 appears to hide/close the cmd windows in a shortcut I've been trying to find a solution for. Here is what I use to open Active Directory Users and Computers via runas with another domain login.

runas.exe /savecred /user:domain\username "cmd /c start mmc C:\Windows\System32\dsa.msc"

perhaps "cmd /c start" is a easy solution...

Alyx Jones

Posted 2010-09-21T15:53:08.873

Reputation: 1

Why do you mention Windows 10. The user was using Windows XP. Have you at least verified this works on Windows XP? – Ramhound – 2015-09-02T18:43:43.527