Home > front end >  the parameter is incorrect shortcut create VB.Net
the parameter is incorrect shortcut create VB.Net

Time:01-10

I'm trying to create a shortcut and I have a problem with this piece of code

      Dim result As DialogResult = OpenFileDialog1.ShowDialog()

        If result = Windows.Forms.DialogResult.OK Then

            Dim str As String = """--start-time=60"

            TargetName = OpenFileDialog1.FileName & str
            ' MyShortcut = System.IO.Path.GetFileName(MyPath)

         End If

receive the following error: the parameter is incorrect (exception from hResult) 0x80070057 ((E invalid arg)))

all I want is to create this piece of code using the shortcut and look exactly like this on the target:

or please, using my directory path to do so for the executable I choose.

"C:\Program Files\MySoftware\Studio\executable.exe" --start-time=120

unfortunately if I only use TargetName = OpenFileDialog1.FileName

This shortcut will create for me: with the code above which is more precisely a function.

"C:\Program Files\MySoftware\Studio\executable.exe--start-time=120

and if I put TargetName = OpenFileDialog1.FileName & str it shows me the above error.

`the parameter is incorrect (exception from hResult) 0x80070057 ((E invalid arg)))`

So how do I solve this problem?

CodePudding user response:

You appear to be putting an extra quotation mark in when you want a space;

Try this:

 Dim str As String = " --start-time=60"
 TargetName = OpenFileDialog1.FileName & str

or if you need quotation marks around the exe, try this:

 Dim str As String = """ --start-time=60"
 TargetName = """" & OpenFileDialog1.FileName & str
  •  Tags:  
  • Related