Search code examples
c#windowscommand-promptwindow-style

Open registered url type from command prompt with window style hidden


I want to open an url type which I have registered in regedit. Namely:

swap://server:port/handle

I want to open it with WindowStyle = Hidden from command prompt. If I do it in C# it is easy:

Process p = new Process();
p.StartInfo.WindowStyle = WindowStyle.Hidden;
p.StartInfo.FileName = @"url:swap://server:port/handle";
p.Start();

However as I said I would like to be able to do the same thing from command prompt. I know how to do it without WindowStyle = Hidden:

start url:swap://server:port/handle

Is there any flag to start which I can set in order to force WindowStyle = Hidden?

Best Regards


Solution

  • There is no way to do this just with cmd, however you can use a simple vbscript to open a batch file with the command you want to run to do this

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run("mybatchfile.bat swap://server:port/handle"), 0, True
    

    Then your batch file would look like this

    start url:%1