View Full Version : Creating shortcut help
John P
07-22-2009, 05:34 PM
First let me say i'm new and I do not script. I am trying to add a shortcut to the desktop via shell create shortcut. i can put in all the info (description, point it to the exe etc) and it works fine.. that is when I hit O.K. it seems like it works fine.. but.. I have command line parameters and when I add those to the shortcut CMDLine I get a syntax error. All I am doing is copying and pasting the command line info from the shortcut properties to this CMDline box. Oh and if it helps.. this is the 3rd action I have in the post install area
Here is the command line parameters:
C:\TNM\System\TNM.exe -hax0r INI="C:\TNM\TNM\System\TNM.ini" USERINI="C:\TNM\TNM\System\TNMUser.ini" log=TNM.log
I have tried with the whole line in quotes and without the quotes. I get an error either way. Here is the error I get:
Without the line in quotes:
Line 3 <name> expected error '\'
If I put the whole thing in quotes I get:
Line=3" ')' expected near 'C'
The setup factory program should not care what my command line says.. it should just add what I tell it to. This is strange to me because it works fine without the command line, but then of course the shortcut will not work.
I know the shortcut works with my command line parameters, there is no error in the command line for the shortcut itself. Please help :-)
jassing
07-22-2009, 05:43 PM
You need to 'escape' your quotes and backslashes....
and you need to seperate it out -- one bit is the "file to run" the 2nd bit is the parameters; assuming you're creating a desktop shortcut, try this:
Shell.CreateShortcut(_DesktopFolder, "My Desktop Shortcut", "C:\\TNM\\System\\TNM.exe", "-hax0r INI=\"C:\\TNM\\TNM\\System\\TNM.ini\" USERINI=\"C:\\TNM\\TNM\\System\\TNMUser.ini\" log=TNM.log", "C:\\TNM\\System", "", 0, SW_SHOWNORMAL, {}, "Sample Shortcut with parameters")
NOTE: This assumes a fixed location -- you should be using SessionVar.Expand("%AppFolder%\\System\\TNM.EXE") etc.
(btw: it's always good to post what you've tried so we can see where you went wrong)
John P
07-22-2009, 06:04 PM
Er.. O.k. here is the whole thing you wish to see:
(sorry I don't know how to put it in code on this forum.)
Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP), "The Nameless Mod Standalone", SessionVar.Expand("%AppFolder%\\System\\TNM.exe"), "C:\TNM\System\TNM.exe -hax0r INI="C:\TNM\TNM\System\TNM.ini" USERINI="C:\TNM\TNM\System\TNMUser.ini" log=TNM.log", "", "", 0, SW_SHOWNORMAL, nil, "");, "", "", , , , "")
The above is the version with errors.
Can you explain more about what it means to 'escape' the quotes and backslashes so I will understand it for future reference?
The file to run.. I assume that's when I pointed the shortcut to the target..
the 2nd bit yes, the command line parameters..
Oh.. I see, the line that is created takes all the info from the above boxes and puts them together as one string. That is where the syntax error comes in at. If I were coding the script by hand, I may know how to avoid the errors but the program does not?? Is that correct?
jassing
07-22-2009, 06:47 PM
Er.. O.k. here is the whole thing you wish to see:
(sorry I don't know how to put it in code on this forum.)
Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP), "The Nameless Mod Standalone", SessionVar.Expand("%AppFolder%\\System\\TNM.exe"), "C:\TNM\System\TNM.exe -hax0r INI="C:\TNM\TNM\System\TNM.ini" USERINI="C:\TNM\TNM\System\TNMUser.ini" log=TNM.log", "", "", 0, SW_SHOWNORMAL, nil, "");, "", "", , , , "")[/QUPTE]
Did you look at my example?
[QUOTE=John P;141335]Can you explain more about what it means to 'escape' the quotes and backslashes so I will understand it for future reference?
some characters are special - namely the " -- which says "this is josh" as a string; but if you wish to say "Josh said "Hi there"" now it's confused, it sees one string of "josh said " and then some jibberjabber, then an empty string ""
so you need to escape the inner quotes
"Josh said \"Hi there\""
the \" will then be interpreted as a " w/in a string.
Now you have a problem with paths "c:\program files\my app" this is interpreted as c:rogra filesy app" since \p and \m don't mean anything like \" does. so you need to now escape the backslash
"c:\\program files\\my app"
This is all VERY standard stuff.
Oh.. I see, the line that is created takes all the info from the above boxes and puts them together as one string. That is where the syntax error comes in at. If I were coding the script by hand, I may know how to avoid the errors but the program does not?? Is that correct?
I used the builder.. the problem is you didn't escape your inner quotes or you backslashes.
Review the differences.
John P
07-22-2009, 07:29 PM
Yeah I put your example and mine side by side and studied them. Your explanation helped a lot.. thanks.. I know it's standard stuff to you, but I am/was trying to get this done without having to learn the script coding. I can see now that it's helpful to know. And I do see the help file has a good guide to learning to script. Thanks again!
jassing
07-22-2009, 07:40 PM
You are welcome -- if you have any issues.. post a new thread!
btw; based on your follow up; this is probably better suited to your needs:
Shell.CreateShortcut(_DesktopFolder, "The Nameless Mod Standalone", SessionVar.Expand("%AppFolder%\\System\\TNM.exe"), SessionVar.Expand("-hax0r INI=\"%AppFolder%\\System\\TNM.ini\" USERINI=\"%AppFolder%\\System\\TNMUser.ini\" log=TNM.log"), SessionVar.Expand("%AppFolder%\\System"), "", 0, SW_SHOWNORMAL, {}, "");
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.