none
Use Process.Start("CMD", start) with unc RRS feed

  • Question

  • Quite simply actually. I have an app that does this and it works:

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click        Process.Start("cmd", "/c start \\server-01\shared$")    End Sub

    However when I want to do the same with a path that has spaces it wont work. Ideas?

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click        Process.Start("cmd", "/c start \\server-01\shared$\Docs & Files\")    End Sub


    //Regards, Andreas

    Monday, July 17, 2017 10:12 AM

Answers

  • Try this:

    Process.Start("cmd", "/c start """" ""\\server-01\shared$\Docs & Files\""")

    • Marked as answer by Plankt0n Monday, July 17, 2017 10:49 AM
    Monday, July 17, 2017 10:43 AM

All replies

  • Try this:

    Process.Start("cmd", "/c start """" ""\\server-01\shared$\Docs & Files\""")

    • Marked as answer by Plankt0n Monday, July 17, 2017 10:49 AM
    Monday, July 17, 2017 10:43 AM

  • However when I want to do the same with a path that has spaces it wont work. Ideas?

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click        Process.Start("cmd", "/c start \\server-01\shared$\Docs & Files\")    End Sub

    You need to enclose in quotes the path that has embedded spaces.

    Now to have quotes within a quoted string you need to double the quotes.

    But a further issue arises in that the start command will interpret the
    first quoted string it encounters as a title for the window. So you
    will need to supply a window title string, and use double quotes to
    ensure that the path is passed to start quoted.

    You will wind up with something like this:

    Process.Start("cmd", "/c start ""cmd"" ""\\server-01\shared$\Docs & Files\""")
    
    - Wayne

    Monday, July 17, 2017 10:47 AM
  • Try this:

    Process.Start("cmd", "/c start """" ""\\server-01\shared$\Docs & Files\""")

    Works like a charm, thank you a lot.

    //Regards, Andreas

    Monday, July 17, 2017 10:49 AM