[RESOLVED] C# Targetpath shortcuts
I have a small problem with generating the shortcut. Actually generating shortcut works no problem but I wont to add other few lines to shortcut that makes me problems that I chouldnt work out. For example :
I need to have the path of my shortcut like this : C:\test.vbs "C:/somefile.exe" somedata [email protected] password
I use this code :
Code:
MyShortcut.TargetPath = @"C:/test.vbs" + textBox3.Text + " " + comboBox1.Text + " " + textBox1.Text + " " + textBox2.Text;
textbox3 is path of somefile. somedata is selected item from combobox. textbox1 is email. textbox2 is password
I can not add the path on textbox3 ( C:/somefile.exe ) the program gets error. what am I doing wrong here ?
Re: C# Targetpath shortcuts
I am guessing that you forgot to put space
Code:
MyShortcut.TargetPath = @"C:/test.vbs " + textBox3.Text + " " + comboBox1.Text + " " + textBox1.Text + " " + textBox2.Text;
Re: C# Targetpath shortcuts
nope it gives me error unhandled exeption again. If I do not put the textbox3 filepath it works with it it doesnt. or if I put only the exe name like : somefile.exe it works also not with C:/somefile.exe
Re: C# Targetpath shortcuts
Well I know nothing about C# but I'm pretty certain you don't use C:/ in a path. Shortcuts aren't urls, are they?
Re: C# Targetpath shortcuts
Shortcut is should be like this : C:\test.vbs "C:/somefile.exe" somedata [email protected] password
Re: C# Targetpath shortcuts
Er ... the fact that you can't make it work suggests otherwise! If C:/somefile.exe is intended as an url then it should surely be file:///C:/somefile.exe and if it's not (which the fact that you can use it with just somefile.exe certainly suggests) it should be C:\somefile.exe
Re: C# Targetpath shortcuts
That looks more like a command string than a shortcut. Shortcuts are ONLY file paths such as C:\someFolder\somefile.exe
shortcut.TargetPath should work perfectly with just "C:\test.vbs".
Re: C# Targetpath shortcuts
sure it works with just a path , if you guys think it looks like a command path YES but how can I do it .
Re: C# Targetpath shortcuts
Quote:
Originally Posted by
españolito
That looks more like a command string than a shortcut. Shortcuts are ONLY file paths such as C:\someFolder\somefile.exe
shortcut.TargetPath should work perfectly with just "C:\test.vbs".
You can use command strings in a shortcut so that's not a problem in itself. I'm assuming that the values given here are just placeholders and not the actual values, of course.
Re: C# Targetpath shortcuts
Quote:
Originally Posted by
dunfiddlin
You can use command strings in a shortcut so that's not a problem in itself. I'm assuming that the values given here are just placeholders and not the actual values, of course.
any example ?
Re: C# Targetpath shortcuts
This is my shortcut for a well known game ...
"C:\Program Files\Out of the Park Developments\OOTP Baseball 13\ootp13.exe" load_league=Play At The Plate.lg
Re: C# Targetpath shortcuts
Quote:
Originally Posted by
RapidBuster
I am guessing that you forgot to put space
Possibly also the Double Quotes.
Looking at dunfiddlin's shortcut, the filepath is enclosed in quotes and the command string follows, separated by spaces.
Re: C# Targetpath shortcuts
well I need my shortcut exact like this :
if anyone can give me an examle on how to do this whould be very nice thank you .
Re: C# Targetpath shortcuts
I did this test and it generates the correct string with the correct quotes as per dunfiddlin's post
Code:
Label1.Text = """C:/test.vbs""" + " " & TextBox3.Text + " " + TextBox4.Text + " " + TextBox1.Text + " " + TextBox2.Text
Obviously, you'd need to change the variable names and also bear in mind this is VB, not C# so you'd need to put the @ and the ; back
Attachment 91669
Re: C# Targetpath shortcuts
I have now like this changed my code , sorry @españolito didnt work in C#
Quote:
shortcut.TargetPath = "\"C:\\file.exe\"";
shortcut.Arguments = "/" + textBox3.Text + "/" + " " + comboBox1.Text + " " + textBox1.Text + " " + textBox2.Text;
this works great , instead of / I need to add " but cant :)