Windows exec Node. start process in the foreground

hello,

i want to launch some programs from my node-red server.
My Problem is that the programs are running but i don't see the window.

example:
command: C:/WINDOWS/system32/notepad.exe
i get a pid and if i lookup the pid in the taskmanager i see the running program.
But there is no notepad window on the desktop.

exec mode:
execution code shown in the TaskManager: C:\WINDOWS\system32\cmd.exe /d /s /c "C:/WINDOWS/system32/notepad.exe"

spawn mode:
execution code shown in the TaskManager: C:/WINDOWS/system32/notepad.exe

It's always worth searching the forum. This question was asked (and answered) 6 days ago here: Open a web browser with EXEC node

1 Like

i'm running node-red as a service created with nssm.

I try to launch it owned by a user.

the Problem with this solution is, that the server isn't hidden anymore.

i want an hidden server that execute visible programs.

edit.: Solved

Solved it with an vbs program.

runHidden.vbs

Set Shell = CreateObject("WScript.Shell")
Shell.CurrentDirectory = "D:\Users\USERNAME\.node-red" 
Shell.Run "D:\Users\USERNAME\AppData\Roaming\npm\node-red.cmd -u D:\Users\USERNAME\.node-red > D:\Users\USERNAME\.node-red\service.log", 0, False

And add this vbs to the Task Sheduler.Set The Task to run as a User (not SYSTEM) and Run only if the User is logged in.

Could have been done with PowerShell instead which would likely be more robust than VBS which is not only old technology and therefore quite likely to disappear over the next few years but also may be blocked on enterprise desktops.

Probably not an issue for you but thought I'd mention it in case someone else comes across this in the future.