How to cancel the "press o"

Hi, I created a batch file that runs n8n and I want to open the browser with localhost:5678 the problem is in the command line he waits for me to press on “o”, and that course that he does not move to the next command, anyone have any solution?
I just want to open the browser automatically after “npm run start”

image

Hi @Asaf_Shay, this would be the default behaviour of Windows batch files. Commands run in sequential order, so the command following npm run start will only run once n8n is shut down again. You might be able to use the start command in your batch file to overcome this as described here: windows - How to start an application without waiting in a batch file? - Stack Overflow

You can then use a second start command to open the browser later as suggested under Open a Web Page in a Windows Batch FIle - Stack Overflow

This really is not an n8n question though (as this is the case for all programs), but one on Windows batch files (which themselves go back to DOS), so this question might be better placed in a Windows community.

thanks but it’s not helping because I want to open the browser after I finish to start the n8n, the solution I found is to add another line in your project
I don’t like it because I need to change your code, but this is all I got

1 Like

Well, forking n8n and changing it to suit your needs is of course always an option :smiley:

This is actually a cleaner solution for your specific case, though it’s unlikely to make it into the actual product, seeing as there are many scenarios where opening the browser is undesired. So it’s a trade-off here: Do you want to maintain your n8n fork (possibly more work, but more elegant) or maintain a batch file (maybe with a waiting time, so might not a 100% fit)? That’s a question I can’t answer for you though.

:+1: thanks

You are most welcome!

If you’d like a third option, I was playing around with Microsoft’s PowerShell on the weekend and it could be the best of both worlds: It allows you to start background jobs (using Start-Job) and then send repeated requests to your local n8n instance (using Invoke-WebRequest) until you get a 200 response before opening the browser.

So this way you wouldn’t have to worry about carrying forward changes to n8n but still open the browser only once n8n is available. I have not build something like this though, but might still be worth keeping in mind.

You could do the same thing with Bash / ZSH as well with (npm run start &) then on Mac it would be something like open http://localhost:5678 and on Linux you would use XDG-Open

Although maybe an easier way now depending on what you are actually trying to do would be to use the Desktop application which takes care of everything for you.