-1

To execute a my application in foreground in win10'cmd:

c:\myapp\app.exe -c c:\myapp\config.json

I want to create a hotkey binding with the above cmd command and execute in background.

Click on desktop--new--hotkey,write the command c:\myapp\app.exe -c c:\myapp\config.json in target menu,named it myapp.

enter image description here

It is no use to write start "c:\myapp\app.exe -c c:\myapp\config.json".

enter image description here

It encounter error when to press apply.

enter image description here

Now there is a hotkey on my win10's desktop,click the hotkey myapp,it execute in foreground,how to make it run in background?

It is no use to write it as start /B c:\myapp\app.exe -c c:\myapp\config.json and select the normal window in run selection menu.

The command c:\myapp\app.exe -c c:\myapp\config.json start my app and show all info in window's cmd console,i want to make it run as a daemon and not to show all info in window's cmd console.

showkey
  • 482
  • 42
  • 140
  • 295

3 Answers3

3

There are several different ways.
Note: None of them work for GUI program like Calc.exe

1. Remove start from the shortcut file, select Minimized for Run

This will create a minimized window, but will automatically close that once the program has finished.


2. Create a Windows Application, not a Console Application if you have the source code.


3. Use Windows Script Host

  1. Create a VBS file as follows.
  2. Create a shortcut of the VBS file and set the Shortcut Key section.
Option Explicit

Dim shell
Set shell = WScript.CreateObject("WScript.Shell")

shell.Run "c:\myapp\app.exe -c c:\myapp\config.json", 0, True

Set shell = Nothing

i want to make it run as a daemon and not to show all info in window's cmd console.

If you want the console to open, but don't want to see messages from the app, then try c:\myapp\app.exe -c c:\myapp\config.json 1>nul 2>&1 .

7cc
  • 1,149
  • 4
  • 10
0

I have something for you to try. Use task scheduler to create a scheduled task that can be run on demand. Set up the task to run hidden. If this task runs your app the way you want, then your shortcut (hotkey) will be:

schtasks /Run /TN "task name"

Set it to be minimized. I haven't tested this, and I don't know if your app will work with this concept. But it's as close as I can come up with since I think you want it to be hidden (background). I believe you will get a "flash" on the taskbar when this runs minimized.

avery_larry
  • 2,069
  • 1
  • 5
  • 17
-1

Either try writing a batch file which contains your "start..." command (and maybe add an exitbelow that line to close the cmd.exe window afterwards). Then create the Shortcut/Link to that batchfile (in the "target" line).

Or just remove the start and the double quotes, just set C:\MyApp\app.exe -c c:\myconfig\config.json as target commandline to execute your app.

Concerning running in Background... You did set "Run" to "Minimized" already, as seen in the screenshot. If you do not want to see any command window, try the switch /B with your start command (execute start /? to see the documentation help on that).

Antares
  • 605
  • 3
  • 14