NOTE: It looks like the batch file needs a parameter - the name of the exe file to run. I haven't tested it myself, but you should try placing the batch file in the same directory as the exe file you want to run, and issue the command from the prompt as follows (for example, if the file name is MyProject.exe) but starting with the full path. This will leave the Command Prompt window open even after MyApp.exe terminates: cmd /K “C: SomeFolder MyApp.exe” You can create a shortcut with the above. This solution works with all console programs and does not require you to go through Command Prompt every time or modify the original.exe file (which you usually cannot).
Categories: Command Prompt
In other languages:
中文: 在Windows或Mac上使用命令提示符运行exe文件, Español: ejecutar un archivo EXE desde la línea de comandos en una PC o Mac, Italiano: Eseguire un File EXE dal Prompt dei Comandi di Windows, Français: lancer un fichier exécutable avec l'invite de commandes (CMD) sur PC, Русский: запустить EXE–файл из командной строки, Nederlands: Een exe bestand openen vanaf de opdrachtprompt in Windows of op een Mac, Português: Executar Arquivos Exe no Cmd no Windows ou Mac, 한국어: PC 또는 맥의 명령 프롬프트에서 Exe 실행하는 방법, ไทย: เปิดไฟล์ Exe ด้วย Cmd (Command Prompt) ใน PC หรือ Mac, Türkçe: PC'de veya Mac'te Exe Cmd'den Nasıl Çalıştırılır, Bahasa Indonesia: Menjalankan File Exe dari Cmd di PC atau Mac, Deutsch: Auf einem PC oder Mac eine EXE Datei von der Kommandozeile aus ausführen, 日本語: Windows PCでコマンドプロンプトからexeを実行する
Run: PSEXEC COMPUTER -u Administrator -p password CMD.exe And you've got the same interactive Command Prompt on COMPUTER that you'd have if you walked over and typed ALT+RCMDENTER. Maybe a little slower, but it's not noticeable unless you're scrolling through a massive amount of text. Even over 10 Base-T it's not too bad. Keep in mind that the best way to open and execute files is through the 'Run Application' Action, or through the ' Cmd Session' group of Actions. The 'Run DOS Command' Action, while it may work for simple commands, is not meant for this kind of interaction, but.
Cmd Run File Command
- Edit
- Send fan mail to authors
Active7 years ago
I have few computers connected to the network and I want to create batch files to automatize the process of working with them. I have already created one used to shutdown computers at once. It is very simple I ll just post it for the sake of argument.
Now I want to execute programs on these machines. So lets say there is 'example.exe' file located 'Slave1-PCdexample.exe'
using
runs it on my computer through network and i didn't come up with anything else. I dont want to use any psexec if possible. Help would be much appreciated.
Peter
Peter Kottas
migrated from stackoverflow.comSep 22 '12 at 21:49
This question came from our site for professional and enthusiast programmers.
2 Answers
If you really can't use psexec, then you could probably rig something up with schtasks (better) or at (worse).
However, I think you'd probably spend more time trying to get those to do what you want than you'd spend in setting up PsExec. Psexec is really quite simple to use and it only needs to be available (as an executable file; no installer needed) on the machine doing the controlling, not on each machine being controlled.
At its simplest, PsExec is very simple:
Also, Mark Russinovich (PsExec's author) has written a primer that 'describes how PsExec works and gives tips on how to use it'. Beyond that, 'PsExec /?' and the manual do provide quite good information.
Mattias AnderssonMattias Andersson
PSEXEC
is very easy and simple to use. You use it basically in the same way you use CALL
or START
(except you give it the target computer and a username and password if needed), and is capable of even launching GUI applications, though you won't be able to see or control it.When used to launch a command-line program with normal
STDIN
/ Console input and STDOUT
and STDERR
output, the program or batch file will act as if you are simply running it on your own machine.I was up and using
PSEXEC
to run diagnostics, defrag.exe, anti-virus programs, and for gathering system information in a shop with over 2,000 PC's without more introduction than PSEXEC /?
within a day.Run Exe Using Cmd Prompt
Run:
And you've got the same interactive Command Prompt on
COMPUTER
that you'd have if you walked over and typed ALT+RCMDENTER. Maybe a little slower, but it's not noticeable unless you're scrolling through a massive amount of text. Even over 10 Base-T it's not too bad.As an Network Administrator able to use the same username / password on nearly every computer, I found that all but the most locked down computers, I didn't even need to use a username or password. This...
...was usually sufficient.
To use your example type:
Or:
PSEXEC
will prompt you for a username and password if they are needed.The first time you connect to a computer you may need to (or get someone else to) allow the connection via a Pop-Up on the remote system.
Run Exe Through Cmd 10
James KJames K