Results 1 to 3 of 3

Thread: [RESOLVED] Passing an arguemtn to a new process with spaces

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Resolved [RESOLVED] Passing an arguemtn to a new process with spaces

    Hey,

    I have run into an interesting problem today and not sure how to work around it.


    In my program I use the Process.Start Method (String, String)

    http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx

    The file it is running is a VB Script and the argument is a path as to where the output file from the script will be save e.g "C:\Documents and Settings\rdlyma\Desktop\"

    I get the path in vb like this
    vb.net Code:
    1. Dim forlder As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\MSU\test"

    Now instead of it taking the entire path as one argument, the path is broken up into arguments whereever there is a space. so "C:\Documents and Settings\rdlyma\Desktop\"
    become "C:\Documents" "and" "Settings\rdlyma\Desktop\"

    vb.net Code:
    1. if Wscript.Arguments.Count > 0 then
    2.                              xmlDoc.Save Wscript.Arguments(0) & ".xml"
    3.                            end if

    that is how it is used in the script
    Last edited by Crzyrio; May 13th, 2013 at 01:44 PM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Passing an arguemtn to a new process with spaces

    You can get around the issue in the Windows Shell or the console by placing such paths inside double quotes so I'd wager you can do it for Process.Start.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2013
    Posts
    177

    Re: Passing an arguemtn to a new process with spaces

    Quote Originally Posted by Niya View Post
    You can get around the issue in the Windows Shell or the console by placing such paths inside double quotes so I'd wager you can do it for Process.Start.
    Thanks!! Worked perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width