Ever since I moved to Windows 7, whenever I am am developing a .bat script I have exactly one chance to get it right. As soon as I execute the script, it becomes locked by an unknown process even if the execution appears to have completed, and I have to force quit explorer or restart to be able to edit the .bat file again.
For example, if I create a .bat file,
@echo off
@start prog\ConsolePortable\ConsolePortable.exe
then realize after executing it that I needed to change some aspect of the script,
@echo off
@cd prog\ConsolePortable
@start ConsolePortable.exe
Then I will not be able to save my changes. For example, in gvim I get the message, "'console.bat' is read-only (add ! to override)," and then when I try to override, I get the message, "E212: Can't open file for writing."
Surely there must be some way of scripting without requiring ProcessExplorer on every computer I use. How does one find the process of a .bat file to stop it, anyway? I tried ProcessExplorer and BSOD'd the compy trying to stop it. I have also tried using cmd /c in place of start.
EDIT: ConsolePortable starts fine here and appears to exit fine, however the following test setup does not freeze the editor:
// Program.java
class Program {public static void main(String[] args) {System.exit(0);}}
// startProgram.bat
echo Starting Program in Java ...
start java Program
echo exiting bat file ...
EDIT 2: Perhaps I should mention that I created the file by using the touch command in cygwin. After restarting the computer, I can't duplicate this problem, though I have encountered it on other computers before.
cmd
window? I'm not exactly sure what the syntax would be, but you could add a command at the end of the .bat to spawn a freshcmd
window (for the next run) and kill the old one, which should free up the file.