Run Notepad.exe using nssm

How can i call and show notepad.exe in my desktop?
i run my node red with nssm service and used exec node to call notepad.. but notepad only show in background (pid process)

can anyone help me ? thanks

If you are running Node-RED under nssm, you probably have it in the SYSTEM context rather than a user. That means that if you simply try to run "notepad.exe" in an exec node, it won't find it.

From a standard PowerShell command prompt, try running whereis notepad.exe. For me, that gives:

image

So using either of those full paths in exec should work.

In general, when running commands from an uncertain context, you should always use absolute file paths and not rely on the shortcuts that users may get.

hi, thanks for your advice and sorry for my late responds

I've tried changing my program, but I still get the result that notepad is running in the background

how do I get it to run on the desktop (foreground)?

Regards..

Your question really begs the question "why". Why are you trying to launch notepad from node-red?

To answer your question - you will need to edit the nssm service and enter the username and password of the logged on user to run node-red. That way, when node-red runs, it runs under the correct account and notepad (when launched from node-red) runs in the same user context.

NOTE: you should export/backup your flows before doing this because when you run node-red under a different account you will get a different set of flows (i.e. node-red will be blank).

1 Like

I actually think it would be better to construct a PowerShell wrapper that changes the user context. Still not sure even that would work though if the service is being run from the SYSTEM context since I'm not sure that even gets a GUI assigned. I'm sure that the mighty Google will turn up someone who has done something similar.