Results 1 to 15 of 15

Thread: [RESOLVED] C# Targetpath shortcuts

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Resolved [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@gmail.com 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 ?

  2. #2
    Member
    Join Date
    Jul 2007
    Posts
    51

    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;

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    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

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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?
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: C# Targetpath shortcuts

    Shortcut is should be like this : C:\test.vbs "C:/somefile.exe" somedata email@gmail.com password

  6. #6
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  7. #7
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    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".

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    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 .

  9. #9
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: C# Targetpath shortcuts

    Quote Originally Posted by españolito View Post
    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.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: C# Targetpath shortcuts

    Quote Originally Posted by dunfiddlin View Post
    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 ?

  11. #11
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  12. #12
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: C# Targetpath shortcuts

    Quote Originally Posted by RapidBuster View Post
    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.

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: C# Targetpath shortcuts

    well I need my shortcut exact like this :

    C:\test.vbs "C:/somefile.exe" somedata email@gmail.com password
    if anyone can give me an examle on how to do this whould be very nice thank you .

  14. #14
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    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
    Last edited by Españolita; Sep 24th, 2012 at 06:34 AM. Reason: add screenshot

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Dec 2011
    Posts
    115

    Re: C# Targetpath shortcuts

    I have now like this changed my code , sorry @españolito didnt work in C#

    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

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