Windows Command Prompt hangs after running batch file - windows

I'm trying to setup a quick batch file where it sets up my development environment when run (on Windows 10). So far, all I'm doing is:
#echo off
w:
pushd directory_of_project
call build.bat //build project
call vsdbg.bat //run a batch file which opens up visual studio's debugger
call 4ed //Open my code editor exe
popd
Everything works fine, except after everything has been setup my command window hangs and I can't Ctrl+C out of it. The command prompt only finishes after closing the 4ed program. Is there a way to modify my batch file to prevent this from happening so I don't have to open up another command prompt window?

I figured it out:
#echo off
w:
pushd directory_of_project
call build.bat //build project
call vsdbg.bat //run a batch file which opens up visual studio's debugger
start 4ed //Open my code editor exe
popd

Related

Run a batch file silentily in NSIS

I have a batch file that needs to vbe excecuted, I am currently executing it using
Exec "$PLUGINSDIR\IISHelper.bat"
But while executing a black window is appearing which is not what is desired. I would like to run that batch file silently.
So I tried
Exec "start $PLUGINSDIR\IISHelper.bat /B"
But while this runs silently this doesn't have the elevated permission as it does for the installer.
The start would not be silent if it worked but it does not because start is not a program, it is a internal command in cmd.exe.
Use the nsExec plug-in (part of the default NSIS installation) to hide the console window.
nsExec::Exec '"$sysdir\cmd.exe" /c if 1==1 "$PLUGINSDIR\IISHelper.bat"'
Pop $0

How to Make a .bat file with arguments

For my work I have to run a string in "run".
I want to make this in a bat file but the arguments are not used but without them the program will not run.
This is the string:
"C:\Program files (x86)\MicroTouch\MT7\TwUI.exe" TwUICP.dll CPMain
Can someone help me with this problem?
You can simply put the same line of code into your bat file:
"C:\Program files (x86)\MicroTouch\MT7\TwUI.exe" TwUICP.dll CPMain
There are some options you can use. For example if you want the program to run hidden in background you can add start /b before the line. start /w will make the cmd window stay open and wait for your program to finish. You can even definde which CPU cores the program should use. For more information open the console and type start /? or check out http://ss64.com/nt/start.html.
Have the same problem, same software i think...
"C:\Program Files (x86)\MicroTouch\MT 7\TwUI.exe" twuicp.dll CPMain
Running that line through task manager -> new task will open a tool to configure touch-screen options, calibrate, etc...
Well same line doesnt work in a bat or cmd file. If i try to launch this tool through cmd.exe it doesnt work either.
The answer is always the same:
USAGE: twui <DLL name> <UI symbol name>
This works, but same line in cmd.exe dont

Batch file: Pause does not keep the window open

I made some batch files for builds etc, and some stay open until I press a key, some don't. Since the batch files are started on doubleclick from explorer, the last command always is pause.
This works:
#echo off
sencha app build testing
pause
This does not work:
#echo off
cscript /nologo newKey.vbs
sencha app build production
copy build\production\MyApp\app.js phonegap\www\
cd phonegap
cordova build android wp8
pause
Why does pause not wait for my keystroke here? Does it get any "keystroke" from the command before?
I am using Windows 8.1, if that matters...
Because cordova is cordova.cmd, a batch file, and when a batch file invokes another batch file the execution flow is transferd to the called batch but does not return to the caller
You will need to use the call command, so the execution flow returns to the caller
call cordova build android wp8

Run an input file using an exe file with cmd

I am using Windows 7
How can i run an input file (text file of commands) in an exe progam in CMD please.
Using other questions on the site, i have tried:
CMD /c ""C:/Program Files/Mplus/Mpluswin.exe" "C:/Users/jj/Desktop/mplus/test_mplus.inp""
which opens the input file in the program but does not run it
and this, which opens the program, but not the script
CMD /c "C:/Program Files/Mplus/Mpluswin.exe" < "C:/Users/jj/Desktop/mplus/test_mplus.inp"
Does this depend on the exe program?
Edit:
At present, the first command above launches the exe program and opens the text file within it (this is a file of program specific commands that will read in data, run calculations and output automatically). I can then run the commands in the exe program that has been opened (by selecting run in a menu) . But, I would like to pass the file to the exe program and it to be run automatically, ideally in the background. I am not sure of the correct terminology to use, so sorry if my description is unclear.
I've just noticed that you enclosed the entire term in an extra set of double quotes, and used linux forward slashes - try this batch file and also see if there is any error message on the console.
#echo off
cd /d "%userprofile%\Desktop\mplus"
"C:\Program Files\Mplus\Mpluswin.exe" "test_mplus.inp"
echo mplus was launched
pause

Visual Studio 2010 - Post-build event - cd "$(ProjectDir)" exits with code 1 when project is loaded from a network drive

I have a solution running in Visual Studio 2010 SP1.
As part of the solution I have a post-build event where the first line is:
cd "$(ProjectDir)"
...
The post build event works fine when the project is loaded locally.
I have setup my laptop with the TFS workspace mapped to a network drive. The solution builds and the website runs just fine - except for the features relying on the post-build event. I have removed all of the Post-build event except the change directory line.
This is the error I get when I build: The command "cd "\\[ComputerName]\b$[ProjectPath]\"" exited with code 1.
The solution is residing solely on the network drive, and it build and runs. I can navigate to the directory in an explorer window without any problems (I saved the network credentials).
The only thing I can find through searching is that exit code 1 means that the path is incorrect, but I can copy and paste the path from the error into an explorer window and browse the directory on the network drive.
Any ideas why the change directory command wont work?
CD is a command used by your shell command interpreter (CMD.EXE).
You cannot pass a CD \\server\share command to CMD.EXE.
Instead I suggest to map your share name to a drive letter like (from the command prompt)
NET USE Z: \\server\share /PERSISTENT:YES
Now you could write a batch file that uses your Z: drive and executes the commands required
For example
CD Z:\projectfolder\bin\release
copy *.exe z:\projectfolder\distribution /Y
You could also pass the predefined macros to this batch file as arguments and use them inside the batch file.

Resources