cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
aclayto87
Level 5

AddFolderIcon Trouble!

Hi everyone,
I am trying to write some installscript code to add a shortcut to the startup of the Technician account only. So i am getting the shortcut added just fine, the problem is the correct path is not being created to the actual program. here is what i have so far, but i must be messing up one of the values because it seems like i have tried every combination of ways to put the correct path to the program in there but it is not working, and is not launching the program since the path is incorrect.

szProgramFolder = "C:\\Users\\Technician\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup";
szItemName = "ShortcutName"; //different than name of .exe
szCommandLine = "C:\\Program Files\\ProgramToLaunch.exe";
szWorkingDir = "";
szIconPath = "";
nIcon = 0;
szShortCutKey = "";
nFlag = NULL;

nResult = AddFolderIcon ( szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath, nIcon, szShortCutKey, nFlag );

if(nResult < 0) then
MessageBox("Shortcut NOT Added for Technician account", SEVERE);
else
MessageBox("Shortcut Successfully Added for Technician account", INFORMATION);

endif;



Any help is greatly appreciated!
if you can see where i have gone wrong and what is causing the path to the executable to show up incorrectly please let me know

(i have looked at many examples and help files, but somehow am still not getting it!)

thanks!
Alicia
Labels (1)
0 Kudos
(2) Replies
RobertDickau
Flexera Alumni

In the shortcut's properties, what does the target look like?
0 Kudos
aclayto87
Level 5

Finally was able to figure it out, what i needed to do was have the szCommandLine as a LongPathToQuote, but not the szProgramFolder.
I am still not sure why it didnt want both of them as LongPathToQuote, but after many trials and errors it seems that using LongPathToQuote for the szCommandLine will place the correct path for the shortcut and it finds the executable.

the thing is i did change the szCommandLine from "C:\Program Files\ProgramToLaunch.exe" to PROGRAMFILES^"\\ProgramToLaunch.exe"
and then sent that value (szCommandLine) to the LongPathToQuote function, and for some reason this works just how i need it to .... i dont think i tried it before when it was "C:\Program Files\ProgramToLaunch.exe" so it is possible it would have worked this way too.

Anyway thanks for the response, it was one of those things where i was changing so many things, finally got it to work and dont really know why it does now lol. i should go back and try it as "C:\Program Files\ProgramToLaunch.exe" just to see if that would have worked also.

Not sure why i wasnt able to use 2 LongPathToQuote functions before then calling the AddFolderIcon function. But when i reduced it down to one LongPathToQuote call it worked.
0 Kudos