I am trying to create a batch file that opens a RethinkDB database.I need to execute it like this
rethinkdb.exe -http-port <portno>
How can i do this from a batch file?I just wanted to start the script.The port will be hard-coded in the script.
I tried:
#echo off
cd /d "C:\Users\username\Desktop\personal\wsrethink"
start "" rethinkdb /path:"C:\Users\username\Desktop\personal\wsrethink\rethinkdb.exe" --http-port 9300
timeout 10
pause
Try this
#echo off
start "" /D "C:\Users\username\Desktop\personal\wsrethink" rethinkdb.exe --http-port 9300
timeout 10
pause
Related
I would like to start 3 commands in the same window.
For now I have this batch but there are 3 different windows at each command.
start /d "c:\Program Files\myfolder" cmd /k cscript A
timeout /t 6 >nul
start /d "c:\Program Files\myfolder" cmd /k cscript B
timeout /t 6 >nul
start /wait /d "c:\PProgram Files\myfolder" cmd /k cscript C
What should I modify to have only one window? thanks
I think you can run a .bat file by changing the directory like so, cd C:\PATH\TO\DIRECTORY\WITH\FILE, then use call (file name here). This should work assuming that all the files are in the same directory, if not you'll just have to change the directory for each call method. If my code doesn't seem very helpful, check this page out https://superuser.com/a/1062322
Example Code
#echo off
cd PATH\TO\FILE\DIRECTORY
call FILE NAME
echo The file (file name here) has run!
pause
this code will make a call to the file and pause the terminal to keep it opened. You can take this code and make as many calls/cd's as you like. I hope this helped, If it doesn't work, please tell me what doesn't work and I'll try to fix it. Have a nice day :)
I'm trying to execute a batch file but its console is not stopping for its output.
here's the code:
goto D:
cd postgresql-9.6.0-1-windows-x64-binaries
cd pgsql
cd bin
start pg_ctl start -D D:\pg_data\data
#echo on
echo server started
pause
I am assuming it is on the D: drive. use cd /d see cd /? for the reason why.
#echo off
cd /d "D:\postgresql-9.6.0-1-windows-x64-binaries\pgsql\bin"
start "" "pg_ctl" start -D "D:\pg_data\data"
echo server started
pause
change to start "" /wait if you want to wait for the service to start before you echo it has been started.
i want to watch a folder on my Win7 64bit Machine for new pdf files - and print them autmatically when there is a pdf file in the folder. After printing, the pdf file should be moved in a subfolder. So, after some google research i did a small batch file.
cd "D:\print"
for %%i in (*.pdf) do (
"C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" /print "%%i"
timeout /T 10 /nobreak
move D:\print\*.pdf D:\print\printed
echo %%i
)
I stored this in folder d:\print as print.cmd . When i start the cmd by doubleclick, my printer starts working and the pdf file moves to the subfolder i defined (D:\print\printed).
To watch the folder, i had the idea to create a sheduled task that repeat this cmd-script all 5 minutes.
BUT:
This dont work, when the script is started via scheduled tasks, the printer is not working - the "movement" of the file instead, is working.
I entered in the scheduled task:
Program: C:\Windows\SysWOW64\cmd.exe
Argument: /c"d:\print\print.cmd"
Any idea, why i cant acces the printer via the scheduled task?
The printer is connected via usb.
Hope i could provide necessary information! Thanks for your answers!
Change this line: move D:\print\*.pdf to move /Y D:\print\%%i
Point the scheduled task to actually start your batch file instead of calling cmd and putting the path to your script in the arguments.
You could also edit the batch file and code it to loop every 5 minutes so you only have to start it once:
PushD %~dp0
:start
for %%i in ("D:\print\*.pdf") do (
"C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe" /print "%%i"
move /y "%%i" "D:\print\printed"
echo %%i
)
timeout /T 300 /nobreak
goto start
I wrote a batch file for open a specific program but it is not working.I wrote this :
#echo off
C:\Windows\System32\cmd.exe /K "cd /d C:\Program Files (x86)\HTC\HTC Sync Manager\"
start HTCSyncManager.exe
When I run the batch file only this window come, program do not start. How to fix this
#echo off
For /r c: %%f in (path goes here /HTCsyncmanager.exe) do (
start "%%f"
"%%f"
)
Remove the invoking of cmd.exe. All that's doing is starting a new instance of the command processor, which is not what you need at all. (You probably don't need the start, either.)
#echo off
cd /d "C:\Program Files (x86)\HTC\HTC Sync Manager\"
HTCSyncManager.exe
#echo off
start "HTCSyncManager" "C:\Program Files\(x86)\HTC\HTC Sync Manager\HTCSyncManager.exe"
This will open HTCSyncManager.
I want to write a batch file that will do following things in given order:
Open cmd
Run cmd command cd c:\Program files\IIS Express
Run cmd command iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
Open Internet Explorer 8 with URL= http://localhost:8088/default.aspx
Note: The cmd window should not be closed after executing the commands.
I tried start cmd.exe /k "cd\ & cd ProgramFiles\IIS Express", but it is not solving my purpose.
So, make an actual batch file: open up notepad, type the commands you want to run, and save as a .bat file. Then double click the .bat file to run it.
Try something like this for a start:
c:\
cd c:\Program files\IIS Express
start iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
start http://localhost:8088/default.aspx
pause
I think the correct syntax is:
cmd /k "cd c:\<folder name>"
This fixes some issues with Blorgbeard's answer (but is untested):
#echo off
cd /d "c:\Program files\IIS Express"
start "" iisexpress /path:"C:\FormsAdmin.Site" /port:8088 /clr:v2.0
timeout 10
start http://localhost:8088/default.aspx
pause
cmd /c "command" syntax works well. Also, if you want to include an executable that contains a space in the path, you will need two sets of quotes.
cmd /c ""path to executable""
and if your executable needs a file input with a space in the path a another set
cmd /c ""path to executable" -f "path to file""
#echo off
title Command Executer
color 1b
echo Command Executer by: YourNameHere
echo #################################
: execute
echo Please Type A Command Here:
set /p cmd=Command:
%cmd%
goto execute
start cmd /k "your cmd command1"
start cmd /k "your cmd command2"
It works in Windows server2012 while I use these command in one batch file.
cmd /k cd c:\
is the right answer
I was trying to run a couple of batch files parallely at startup, if a condition was true.
For this I made a parent batch file which should have checked for the condition and invoke the other child batch files if the condition was true.
I tried to achieve it via START but it gave me an empty black command prompt running in the directory of children batch files, instead of running the children batch files themselves
The thing which worked for me was by using a combination of START and CALL
As an example
condition ...
start call "C:\Users\Amd\conn\wsl_setup - conn1.bat"
start call "C:\Users\Amd\conn\wsl_setup - conn2.bat"
start call "C:\Users\Amd\conn\wsl_setup - conn3.bat"
I know DOS and cmd prompt DOES NOT LIKE spaces in folder names. Your code starts with
cd c:\Program files\IIS Express
and it's trying to go to c:\Program in stead of C:\"Program Files"
Change the folder name and *.exe name. Hope this helps