manuelmayer-dev / Macro-Deck-Windows-Utils-Plugin

A collection of some useful functions for controlling Windows
MIT License
9 stars 15 forks source link

Run commandline commands in the background #3

Open manuelmayer-dev opened 2 years ago

manuelmayer-dev commented 2 years ago

Currently commandline commands and applications (even if they support silent mode) are started in the visible window, taking focus onto themself and interrupting fullscreen applications.

It would be great if they would run completely silent in the background. And maybe someone also interested in separate options to run PowerShell and WSL scripts, not only regular command line.#

Issue originally created by @zedalert in the Macro Deck repository

akasubi commented 3 months ago

This can be done by adding CreateNoWindow = true, to the ProcessStartInfo created at line 35 in https://github.com/manuelmayer-dev/Macro-Deck-Windows-Utils-Plugin/blob/master/Actions/CommandlineAction.cs so that it reads

                StartInfo = new ProcessStartInfo("cmd.exe")
                {
                    UseShellExecute = false,
                    CreateNoWindow = true,
                    WorkingDirectory = workingDirectory,
                    Arguments = "/C " + command,
                    RedirectStandardOutput = saveVariable,
                }

edit: I noticed that I've used both WindowStyle = ProcessWindowStyle.Hidden and CreateNoWindow = true in my own code. I suppose that was a mistake, as setting WindowsStyle doesn't make sense if no Window is created.

The-Doggo commented 1 month ago

Will this feature ever be implemented?