Search code examples
batch-filewindows-console

.bat file stuck at opening notepad document, not cancellable


As I write bat file very infrequently, every time I write a new one gets me a new problem.

I have a bat file that is suppose to open a txt file and open an URL (which is a concatenated string, using current date), something like:

@echo off
notepad "C:\Users\username\somefile.txt"
start chrome "https://domain.com/%DATE%?some=parameters"

The text file opens fine and then nothing happens - console window gets stuck, not responding to ctrl-C. Apparently batch is suspended waiting for the notepad part to complete, because when I close the txt file window chrome opens the URL.

I tried < nul, > nul for the notepad part, but to no avail. What am I doing wrong?


Solution

  • If I see this correctly, you just need to use start with notepad also. It starts programs in another process so the script can continue.

    @echo off
    start notepad "C:\Users\username\somefile.txt"
    start chrome "https://domain.com/%DATE%?some=parameters"