Jump to content

Creating shortcuts at installation time


Yzöwl

Recommended Posts

  • 1 month later...

[...]The only double quotes required in my tests seemed to be those shown. The only difference was that in VISTA, if newlink-name includes spaces those spaces are replaced with underscores.

Tests using Windows 2000 may indicate otherwise.[...]

Hi Yzöwl :)

I've tested this on Win2k, and with this OS, then to make a valid shortcut, i need the following amount of double-quotes(no matter if there's any spaces or not):

[Version]
Signature=$Windows NT$

[DefaultInstall]
UpdateInis=updateinis

[updateinis]
setup.ini,progman.groups,,group1=%16410%\Microsoft\Internet Explorer\Quick Launch
setup.ini,group1,,"Regshot unicode,""""""%16422%\Regshot unicode\Regshot.exe""""""

When you look at the above line, then i don't understand why it works, since IMHO, there should be an extra double-quote at the very end of the line, but it works nonetheless, and it also works if i add that extra double-quote, so i just omit it, as it's redundant then...

Anyway, i would like to ask you if you would please explain to me why there is ever a need for more than three double-quotes before or after a word i.e. like the above example? I do understand that the INF parser strips the first double-quote away at each sides, and then we can have a double-quote after that, which then in turn needs to be escaped by another double-quote, but that's still just three at the most, so how come the above example and other INFs i've seen use e.g. 5 double-quotes at each side?

I hope you don't mind me asking you this question, but it's just since i know that you are the inhouse NT Command Script/INF wizzard :)

Thanks in advance.

Link to comment
Share on other sites

I think it's got something to do with the fact, your inf is basically writing an ini file, that file then needs to be read and in order for the target to have double-quotes, the ini would need to have escaping double-quotes. In order for the ini to have both sets of quotes the inf needs to do the same.

Anyway, I've tested in Windows 2000 and updated the appropriate previous post to suit all 3 OS's.

Here is the working test I used for your file on Win2k:

[Version]
Signature = "$Windows NT$"

[DefaultInstall]
UpdateInis = AddLink

[AddLink]
setup.ini, progman.groups, ,\
group1=%16410%\Microsoft\Internet Explorer\Quick Launch
setup.ini, group1, ,\
"Regshot Unicode,""""""%16422%\Regshot Unicode\Regshot.exe"""""""

Link to comment
Share on other sites

I think it's got something to do with the fact, your inf is basically writing an ini file, that file then needs to be read and in order for the target to have double-quotes, the ini would need to have escaping double-quotes. In order for the ini to have both sets of quotes the inf needs to do the same.

Ahh, i see! Thank's alot for the clarification!

Anyway, I've tested in Windows 2000 and updated the appropriate previous post to suit all 3 OS's.

Here is the working test I used for your file on Win2k:

[Version]
Signature = "$Windows NT$"

[DefaultInstall]
UpdateInis = AddLink

[AddLink]
setup.ini, progman.groups, ,\
 group1=%16410%\Microsoft\Internet Explorer\Quick Launch
setup.ini, group1, ,\
 "Regshot Unicode,""""""%16422%\Regshot Unicode\Regshot.exe"""""""

1. Why have you added two backslashes(not in the paths)?

2. Why have you added one extra double-quote than in my example? Is it because it is the more correct syntax? Or are my example not working on your tests?

(I always myself preffer to make Command Scripts/INFs as small as possible, like e.g. why use MD, when XCOPY always makes the destination dir if not existing when adding a backslash, and also why use the /i switch of xcopy, when a backslash does exactly the same and is one byte shorter, but that's just me - I preffer smaller size over strict syntax correctness...)

Link to comment
Share on other sites

1. Why have you added two backslashes(not in the paths)?
They serve as line concatenation symbols in inf files. This means that I can break the line of code and continue on the next line without spoiling the reading of the line by having it too long. You'll very likely have seen something similar used for REG_BINARY code in .reg files.
2. Why have you added one extra double-quote than in my example? Is it because it is the more correct syntax? Or are my example not working on your tests?
Yes simply because it's correct syntax and prevents possible mistakes later if you decide to include any of the following; icon-file-name, icon-index, profile or start-in-location.
Link to comment
Share on other sites

  • 4 months later...
The only double quotes required in my tests seemed to be those shown. The only differences were that in VISTA and Windows 7, if newlink-name includes spaces those spaces are replaced with underscores.

This is a problem I am trying to deal with right now. The shortcut works, but I would like the underscores to be spaces.

I guessed that it may have something to do with the number of double-quotes, as discussed in this thread, so I made a small INF file with multiple lines using various numbers of double quotation marks, hoping that one of them would look right. Here is the relevant part of the INF:


setup.ini, group1,, """"Str ing3""",""""""%10%\Test\file.exe"""""",,,,""%10%\Test"",""file.exe"""
setup.ini, group1,, """""Str ing4"""",""""""%10%\Test\file.exe"""""",,,,""%10%\Test"",""file.exe"""
setup.ini, group1,, """"""Str ing5""""",""""""%10%\Test\file.exe"""""",,,,""%10%\Test"",""file.exe"""
setup.ini, group1,, """""""Str ing6"""""",""""""%10%\Test\file.exe"""""",,,,""%10%\Test"",""file.exe"""

Unfortunately, in each case spaces turn into underscores - so I think it is of reason to assume that the culprit is not in the number of double-quotes.

Can someone tell me whether there is a solution to this problem? Or maybe it is time to switch from SetupAPI to something else?

Link to comment
Share on other sites

  • 2 weeks later...

Thank you for the quick response.

I managed to make it work, but my feelings about it are still pretty mixed. The good news is that the shortcut is created and the spaces are there. There are several problems though:

  • I cannot delete the shortcut
  • It is not created with "working dir" pointing to the right folder

I've tried twisting it in many ways, and have consulted other sources; I get the feeling that the entire world knows about ProfileItems, except me :-)

From what I understand, a shortcut created with ProfileItems can be removed by providing its name and a special flag:

[AddTest.DelShortcut]
Name =ACME distorter,0x0000000A

Another source proposes a different method, but I believe it is not applicable in my case because the path is not fixed (in the final product it is supposed to be a custom path entered by a person, so App_ProgramFolder at the end of this post is just a stub).

I intend to test it this way (also tried copying installer.inf to \windows\inf, just to be sure it is not a problem with the path:

RunDll32 advpack.dll,LaunchINFSection d:\test\installer\installer.inf, DefaultUninstall

The shortcuts are still there.

Here is the complete .inf:

[Version]
Signature = $Windows NT$

[DefaultInstall]
;UpdateInis=CreateStartMenuFolder
AddReg = RegAddUninst
ProfileItems = AddTest, AddTestEx

[DefaultUnInstall]
ProfileItems=AddTest.DelShortcut

[AddTest.DelShortcut]
Name =ACME distorter,0x0000000A,
;SubDir =Sub Directory


[RegAddUninst]
HKLM,%SMWCV%\Uninstall\%Soft_Name%,DisplayName,,"ACME"
HKLM,%SMWCV%\Uninstall\%Soft_Name%,UninstallString,,"RunDll32 advpack.dll,LaunchINFSection d:\test\installer\installer.inf, DefaultUninstall"


;16422 = program files
[AddTest]
Name = ACME distorter
SubDir = %Provider%
Infotip = "This is a tooltip weeha!"
CmdLine = 16422, "%Provider%\Distorter", Acmedist.exe
WorkingDir = 16422, "%Provider%\Distorter"

[AddTestEx]
Name = %Soft_Name%
SubDir = %Provider%
Infotip = "This is a tooltip weeha!QQQQQQ"
CmdLine = 16422, "%Provider%\%Soft_Name%", Acmedist.exe
WorkingDir = 16422, "%Provider%\%Soft_Name%"


[Strings]
SMWCV="Software\Microsoft\Windows\CurrentVersion"
Provider="ACME"
Soft_Name="ACME distorter 5.0"
AppLink="ACME distorter 5.0"
App_Name="ACME distorter 5.0"
App_StartMenuFolder="ACME\Distorter 5.0"
App_ProgramFolder="ACME\Distorter 5.0"
ShortCutFileName="ACME\Distorter 5.0.lnk"
PathAndFileName="ACMEdist.exe"
Arguments= ""

In the same context, I would like to get back to the original problem - is there a way to understand why the spaces are replaced with underscores? I've spent a few days testing this workaround and completely forgot the fact that the original problem is much more simple in its nature. Perhaps I am exploring the wrong path?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...