first of all, I knew this question is duplicated but I'm new to bat file and I don't know how to develop this structure.
I want a bat file that works with windows task schedule at a specific time automatically.
I manually use this command in cmd
php\php.exe -f processmaker workspace-backup workflow
then I press enter in cmd to run this command
after that
I manually use this command in cmd
SET PATH=C:\Program Files\MySQL\MySQL server 5.6\bin
then I press enter in cmd again...
ok I want a solution to pressing "ENTER KEY" automatically between these commands.
Can you please help me?
If you edit a text file and name it, say mytask.bat
All the lines in it are executed as if in the command line, so try it, it should work.
Related
I am a new programmer, i have created a batch file to open a website but i want that batch file to run when the computer starts.
Here's the code:
#echo off
:top
start iexplore.exe http://www.website.com
timeout 3
goto top
While i do think Arescet's answer will work, i am more in favor of using Windows' Task Scheduler.
Simply create a new task :
Assign it's trigger to be At Startup :
and add a new action to Start a program giving it the path to your batch file:
I believe this is a cleaner approach which also provides you with logging and history should you decide to do more things in your batch file later on
Type run into windows search, type shell:startup in the prompt, press enter, Then, create a shortcut of your program, and move the shortcut into the startUp folder.
On note of your code, the start command should have a blank title as "", and quotes around the application name and parameters passed, like:
start "" "iexplore.exe" "http://www.website.com"
Hello I'm getting sick from repeating commands in the cmd window so I want a .bat file that makes cmd opens then execute the command, and would be great if it's closed after executing the commands like example:
ipconfig/release
ipconfig/renew
Then closes the cmd window
Thanks.
Easy:
Put both commands in a text file, name it "new.bat".
Add a #echo off and a exit, and you are done:
#echo off
ipconfig/release
ipconfig/renew
exit
Every time, when you enter new, it will execute these commands.
And you can even do it with a double-click in WindowsExplorer.
You could save the .bat file to the desktop, so you can reach it easy with your mouse.
Currently I want to run a batch file that fires the command git log and show me that log.
After that I need to be able to commit and view the status so this prompt may not disappear after a key press.
I've searched the net and the only answer people have is pause which close the prompt after a keypress.
Does anyone have the solution for me? Currently I made a shortcut to cmd.exe and made the target my folder, but I want to execute some commands also.
Thanks in advance.
This (below) tested OK in Windows 7. To exit the window it creates, type "exit" when done.
start cmd /K "cd \[the-target-folder] && git log"
Where:
[the-target-folder] you replace with your target folder
Note:
&& lets you run two commands on one line
/K is a parameter to the cmd shell program which which carries out the command specified by string and remains.
I have creted a batch file that I want to run the SetupCodeGroup.exe
When I double click the batch file it doesnt run the exe file. A command prompt opens up but it doesnt run the file. Can someone tell what I missed or what I am missing
C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
type pause on the next line and check whether this executable comes on the command prompt .
try
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
moreover
start /d "path_to_file_directory" program.exe
is the complete line to execute program and console will not wait to program to exit .
I wonder if this exe requires administrative privileges. Try right-clicking the batch file and running it as administrator.
#echo off
start C:\Users\raw008\Desktop\Critcare\SetupCodeGroup.exe
echo Done
pause
try that if that dose not work then your computers privleges are messed up, i ran into the same problem on my cousins computer.
I have a *.exe console file.
I enter my inputs, and everything is great.
but when I enter the last input, the command window closes (because the program has ended)
before I can read the last output.
is there a way to run that *.exe file and force it to stay open after the program ends?
note: this is not my program. I can't edit the source code, so I'm not looking for answers like "add while(1) or scanf at the end".
Thanks ahead.
Just open a command prompt and run it, the way it's meant to be used.
Start -> Run -> cmd.exe
or Win+R -> cmd
Run the program from command prompt (Start-Run-cmd.exe)
Make a batch file (*.bat), with the command you want to execute, followed by pause:
myconsoleapplication.exe
pause
Save it, and run. The command window wil wait for enter to be pressed before closing.
Run it from the console, or in a batch file.
Start >> Run >> cmd.exe
Then the console window is already open.
This should work:
system("pause");
At the top of your program, include stdlib.h:
#include <stdlib.h>
You can open a command prompt window and navigate (the cd command) to the directory containing the .exe file. Then, run the program by typing its name. The window will not close after the program finishes running.
You could execute this program from one of your own, redirecting stdio and adding your own pause after it terminates. I've done this with .NET but assume that it can be done through other means. Of course a batch file, as mentioned already, is wicked simpler.