This should start a new CMD process in the background without any new CMD/Shell window which is named “Cloudflare”, so you will still be able to find it in the taskmanager.
For more info, please run:
HELP START
which shows you all possible parameters etc.
Another option is to install Windows own SSH Server (musst be installed seperately) and run the command through it, like this:
ssh username@localhost "command to start"
This will also survive the closing of the parent CMD/Shell
I had the same question today and this thread popped up. I’ve gotten closer with some trial an error.
If you want the user to control (and exit) cloudflared, I would think the OP’s original batch file is pretty close. The /min parameter should run cloudflared in a fairly unobtrusive, minimized command window. They can close cloudflared by closing the window.
This post lists several other alternatives to running batch files silently:
The scheduled task idea doesn’t work because to be fully hidden it has to run in a different user process, which means it won’t be able to launch the browser prompt for authentication.
That gives only a brief command window flash before disappearing. Not bad.
VBScript - haven’t tried - create the script run_hidden.vbs:
Set objShell = CreateObject("WScript.Shell")
objShell.Run """path\to\your\executable.exe""", 0, False
then execute from a command file:
cscript.exe "path\to\run_hidden.vbs"
Supposedly this approach has no command window flash.
How to stop it?
What if cloudflared is running hidden and the user needs to restart the RDP session? They click on the command file and another instance of cloudflared starts, on a different port… They could find cloudflared in Task Manager to end the task, or you could write another script to kill cloudflared (maybe use pskill). Maybe the simplest thing would be to use a static port, set up Remote Desktop to use that port, then just let cloudflared run until the user logs off (it’s pretty small: 150 handles / 13MB).