Jump to content

Creating shortcuts at installation time


Recommended Posts

Posted

@MioKawaii

thanx man.I'll try you advice then i'll try the one of Yzwol

@Yzwol

thanx......I'll give it a shot and tell ya what happened , O'right?


  • 1 month later...
Posted

unfortunately non of your commands work with me

Neither:

REG ADD %KEY%\050 /VE /D "Adding User Defined Shortcuts" /f
REG ADD %KEY%\050 /V 1 /D "rundll32 setupapi,InstallHinfSection DefaultInstall 132 %CDROM%\Softwares\shortcuts.inf" /f

Nor:

reg add %KEY%\050 /ve /d "Adding User Defined Shortcuts" /f
reg add %KEY%\050 /v 1 /d "%systemroot%\system32\rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 132 %CDROM%\Softwares\shortcuts.inf" /f

I donno what's wrong?1

Posted

@ Wesmosis

If you posted your entire cmd file, in an appropriate format, it may help, although my first guess is that you are lacking a 'set' statement for your CDROM variable.

Posted

first of all thanks 10000000

so

i wont to install the file shortcuts.inf

by using Aprogram WPI not RunOnceEx.cmd

what can i do?

Posted (edited)

Please read previous responses to Wesmosis for RunOnceEx.cmd syntax, and adjust accordingly for your preferred installation method. The command you need is the bit inside the quotes.

<Edit>

I find all methods beyond batch and inf files a waste of time, therefore I have never even attempted to look at their syntax and implemetation methods.

However for my own curiosity, I took a 10 second glance at the Home Page and guess it'll be something like this

['rundll32 setupapi,InstallHinfSection DefaultInstall 132 %CDROM%\\Softwares\\shortcuts.inf']

</Edit>

Edited by Yzöwl
  • 3 years later...
Posted (edited)

No waranty for any crashes or damages.

Please be careful when you "play games" in your registry!

Dear all,

i know, this is a old topic.

But i want to write my message here.

Ok, for all who want to add shortcuts with inf script's, i have a working example here for you.

It is a unattended script to install "poweroff 3.0.1.3" from Jorgen Bosman.

This is my working code description for a Link.

setup.ini, 001,,"""(LNK NAME)"",""""""(PATH TO FILE)"""" (PARAMETER)"","""""(ICON FILE)""""",(ICON INDEX),,""""""(START IN DIR)"""""",,""(LNK DESCRIPTION)"""

setup.ini, 001,,"""Help"",""""""%11%\poweroff.exe"""" /?"","""""%11%\shell32.dll""""",23,,,,""Command line switches"""

if you want to run the script form command prompt or .CMD/.BAT file you must go to the folder where the script is

located.

i.e.:

CD "D:\Documents and Settings\admin\Desktop"

"%SystemRoot%\System32\rundll32.exe" setupapi,InstallHinfSection DefaultInstall 132 .\poweroff.inf

(This example is working on Windows XP Pro SP3 US)

And here is the complete code with uninstall.

[version]
signature="$Windows NT$"
AdvancedINF=2.5,%ADVPKPRMPT%
[DefaultInstall]
RequiredEngine=setupapi
SmartReboot=I
CheckAdminRights=1
AddReg=InstallReg
[DefaultUnInstall]
RequiredEngine=setupapi
SmartReboot=I
CheckAdminRights=1
AddReg=UnInstallReg
[InstallReg]
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","%SoftName%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","Version: %VERSION%%REVISION%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","____________________________"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","Install %SoftName% ...",0,"RunDll32.exe advpack.dll,LaunchINFSection %SoftFILE%, SoftInstall"
[UnInstallReg]
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","%SoftName%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","Version: %VERSION%%REVISION%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","____________________________"
HKLM,"Software\Microsoft\Windows\CurrentVersion\RunOnce\setup","Remove %SoftName% ...",0,"RunDll32.exe advpack.dll,LaunchINFSection %SoftFILE%, SoftUnInstall"
[SoftInstall]
Copyfiles=INFFILE,Progra01
AddReg=AddRegInst
DelReg=DelRegInst
UpdateInis=UpdateInisInst
[SoftUnInstall]
BeginPrompt=BeginPromptUnInstall
EndPrompt=EndPromptUnInstall
AddReg=AddRegRemove
DelReg=DelRegRemove
DelDirs=DelDirsRemove
Delfiles=INFFILE,Progra01
UpdateInis=UpdateInisRemove
[SourceDisksNames]
1="%SoftName% %VERSION%%REVISION%","poweroff.cab",0
[SourceDisksFiles]
%SoftFILE%=1
poweroff.exe=1
[DestinationDirs]
INFFILE=17
Progra01=11
[Progra01]
poweroff.exe,,,2
[INFFILE]
%SoftFILE%,,,2
[AddRegInst]
;Allow rename of protected files (i. e. NTLDR)
HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager","AllowProtectedRenames",0x00010001,"0x00000001"
;
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%",,0x00000000,""
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","DisplayIcon",,"%11%\poweroff.exe,0"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","DisplayName",,"%SoftName% %VERSION%%REVISION% (Remove only)"
;Section to create a Update Subfolder in "Add/Remove Programs"
;HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","ParentDisplayName",,"%ParentDisplayName%"
;HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","ParentKeyName",,"%ParentKeyName%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","DisplayVersion",,"%VERSION%%REVISION%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","Comments",,"%COMMENT%"
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%","UninstallString",,"rundll32.exe setupapi,InstallHinfSection DefaultUnInstall 132 %17%\%SoftFILE%"
;Add Registry key on installation here

;
[DelRegInst]
HKCU,"Software\JoBo\Poweroff"
;HKCU,"Software\JoBo" ;(use it if you dont use any other JoBo software)
[UpdateInisInst]
setup.ini, progman.groups,,"001=%16407%\%SoftName%"
setup.ini, 001,,"""%SoftName%"",""""""%11%\poweroff.exe"""""",,,,,,""%DESCRIPTION%"""
setup.ini, 001,,"""Help"",""""""%11%\poweroff.exe"""" /?"","""""%11%\shell32.dll""""",23,,,,""Command line switches"""
;setup.ini, 001,,"""(LNK NAME)"",""""""(PATH TO FILE)"""" (PARAMETER)"","""""(ICON FILE)""""",(ICON INDEX),,""""""(START IN DIR)"""""",,""(LNK DESCRIPTION)"""

;Uninstallation
[BeginPromptUnInstall]
Prompt=%UNINSTASK% %SoftNAME% %VERSION%%REVISION%?
ButtonType=YESNO
Title=Warning !!!!!!
[EndPromptUnInstall]
Prompt=%SoftNAME% %UNINSTEND%
[DelRegRemove]
HKLM,"Software\Microsoft\Windows\CurrentVersion\Uninstall\%SoftName% %VERSION%"
[AddRegRemove]
[DelDirsRemove]
[UpdateInisRemove]
setup.ini, progman.groups,, "001=%16407%\%SoftName%"
setup.ini, 001,,"""%SoftName%""
setup.ini, 001,,"""Help""
[Strings]
SoftFILE="poweroff.INF"
SoftName="Poweroff"
VERSION="3.0.1.3"
REVISION=""
COMMENT="INF Script by 13/13"
DESCRIPTION="Turn of computer local or remote"
ParentDisplayName="Command line tools"
ParentKeyName="CommandLineTools"
UNINSTASK="Please check if you've removed all services from Poweroff! Do you want to uninstall"
UNINSTEND="uninstallation is finished.
ADVPKPRMPT = "Please install the new Advpack.dll Version 2.5 or above to run the installation!"
[HELP]
;########## Help
;
; REG_SZ = 0x00000000
; REG_MULTI_SZ = 0x00010000
; REG_EXPAND_SZ = 0x00020000
; REG_BINARY = 0x00000001
; REG_DWORD = 0x00010001
; REG_SZ_APPEND = 0x00010008
;
; HKCR = HKEY_Classes_Root
; HKCU = HKEY_Current_User
; HKLM = HKEY_Local_Machine
; HKU = HKEY_Users
; HKCC = HKEY_Current_Config

Best regards MCP

poweroff.inf

Edited by MCP
  • 4 months later...
Posted (edited)

the AutoIT solutions I've seen seem like cop-out solutions and OptimumX's shortcut.exe just does not work. This INF solution seems to be the best to me...but I'm having no luck getting it to work.

Here's my INF.

[Version]
Signature=$WINDOWS NT$

[Shortcuts]
UpdateInis=AddLink

[AddLink]
setup.ini, progman.groups,, "group1=""%16408%""
setup.ini, group1,,"""bginfo"",""""""C:\bginfo.exe default.bgi /timer:0 /nolicprompt /silent"""""""

setup.ini, progman.groups,, "group2=""%16409%""
setup.ini, group2,,"""Windows Media Player"",""""""C:\Program Files\Windows Media Player\wmplayer.exe"""""""

setup.ini, progman.groups,, "group3=""%16409%""
setup.ini, group3,,"""Microsoft Word"",""""""C:\Program Files\Microsoft Office\Office12\winword.exe"""""""


setup.ini, progman.groups,, "group4=""%16409%""
setup.ini, group4,,"""Microsoft Powerpoint"",""""""C:\Program Files\Microsoft Office\Office12\powerpnt.exe"""""""


setup.ini, progman.groups,, "group5=""%16409%""
setup.ini, group5,,"""Microsoft Excel"",""""""C:\Program Files\Microsoft Office\Office12\excel.exe"""""""

here are the lines I added to runonceex.cmd:

REG ADD %KEY%\045 /VE /D "Adding user defined shortcuts" /f
REG ADD %KEY%\045 /V 1 /D "rundll32 setupapi,InstallHinfSection Shortcuts 128 E:\shortcuts.inf" /f

It may be best practice not to hard code the E drive as the path to the inf...but for my computer setup it works fine. Does the INF support switches, as I've attempted with BGinfo?

I bet this problem has something to do with setup.ini but I'm drawing a blank as to what my next step should be

Edited by mrquincy
Posted

First of all you have an imbalance with your 'double-quotes' in your progman.groups lines.

In your inf you could replace C:\ with %24%, and C:\Program Files with %16422%

In order to not hard-code E: you would need to somehow programatically ascertain that letter first.

Posted

Thanks for the quick reply, and good catch.

I've been reviewing your inf code and the technet article http://technet.microsoft.com/en-us/library/dd361909.aspx.

Your inf has significantly more nested quotations than the microsoft example (probably because yours has actually tested working :)). What do I have to gain by maintaining the complexity of the quotations? I also noticed that the technet inf example has a series of three commas after the path to the target exe. What do these three commas represent in the inf syntax?

Posted (edited)

The original example used a few more double quotes than strictly necessary (in order to minimise problems with users using anything at all with spaces in the name).

Here is an updated template, tested in Windows 2000, XP, VISTA and Windows 7

[Version]
Signature="$Windows NT$"

[Shortcuts]
UpdateInis=AddLink

[AddLink]
;creates a new section in the ini file and defines its location
;ini-name,section-name,oldsection-name,newsection-name=intendedlocation
setup.ini,progman.groups,,group4=%16386%\Standalone\Restoration

;creates the link within the defined section of that ini file
;ini-name, section-name, oldlink-name, "newlink-name, exe-name, icon-file-name, icon-index, profile, start-in-location"
setup.ini,group4,,"Restoration,""""""%16422%\Standalone\Restoration\Restoration.exe"""""""

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.

Because VISTA onwards uses a different filing structure here are an updated list of DirID's

;DirID's For Windows Vista Onwards [x86 & x64]

1 = <Location of running inf>
10 = %SystemRoot%
11 = %SystemRoot%\system32
12 = %SystemRoot%\system32\DRIVERS
17 = %SystemRoot%\INF
18 = %SystemRoot%\help
20 = %SystemRoot%\fonts
21 = %SystemRoot%\system32\viewers
23 = %SystemRoot%\system32\spool\drivers\color
24 = %SystemDrive%\
25 = Shared directory
30 = <Root directory of the boot disk>\
50 = %SystemRoot%\SYSTEM
51 = %SystemRoot%\system32\spool
52 = %SystemRoot%\system32\spool\DRIVERS\W32X86 ;(x86 systems only)
52 = %SystemRoot%\system32\spool\DRIVERS\x64 ;(x64 systems only)
53 = %UserProfile%
54 = <Directory where bootmgr.exe is located>\
55 = %SystemRoot%\system32\spool\PRTPROCS\W32X86 ;(x86 systems only)
55 = %SystemRoot%\system32\spool\PRTPROCS\x64 ;(x64 systems only)
16384 = %UserProfile%\Desktop
16386 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
16389 = %UserProfile%\Documents
16390 = %UserProfile%\Favorites
16391 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
16392 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Recent
16393 = %UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo
16395 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Start Menu
16397 = %UserProfile%\Music
16398 = %UserProfile%\Videos
16400 = %UserProfile%\Desktop
16403 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Network Shortcuts
16404 = %SystemRoot%\Fonts
16405 = %UserProfile%\AppData\Roaming\Microsoft\Windows\Templates
16406 = %AllUsersProfile%\Microsoft\Windows\Start Menu
16407 = %AllUsersProfile%\Microsoft\Windows\Start Menu\Programs
16408 = %AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\Startup
16409 = %Public%\Desktop (%UserProfile%\..\Public\Desktop)
16410 = %AppData%
16411 = %AppData%\Microsoft\Windows\Printer Shortcuts
16412 = %LocalAppData%
16413 = %AppData%\Microsoft\Windows\Start Menu\Programs\Startup
16414 = %AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\Startup
16415 = %UserProfile%\Favorites
16416 = %LocalAppData%\Microsoft\Windows\Temporary Internet Files
16417 = %AppData%\Microsoft\Windows\Cookies
16418 = %LocalAppData%\Microsoft\Windows\History
16419 = %ProgramData%
16420 = %SystemRoot%
16421 = %SystemRoot%\system32
16422 = %ProgramFiles%
16423 = %UserProfile%\Pictures
16424 = %UserProfile%
16425 = %SystemRoot%\SysWOW64 ;(x64 systems only)
16426 = %ProgramFiles(x86)% ;(x64 systems only)
16427 = %CommonProgramFiles%
16428 = %CommonProgramFiles(x86)% ;(x64 systems only)
16429 = %AllUsersProfile%\Microsoft\Windows\Templates
16430 = %Public%\Documents (%UserProfile%\..\Public\Documents)
16431 = %AllUsersProfile%\Microsoft\Windows\Start Menu\Programs\Administrative Tools
16432 = %AppData%\Microsoft\Windows\Start Menu\Programs\Administrative Tools
16437 = %Public%\Music (%UserProfile%\..\Public\Music)
16438 = %Public%\Pictures (%UserProfile%\..\Public\Pictures)
16439 = %Public%\Videos (%UserProfile%\..\Public\Videos)
16440 = %SystemRoot%\resources
16441 = %SystemRoot%\resources\0409
16442 = %AllUsersProfile%\OEM Links
16443 = %LocalAppData%\Microsoft\Windows\Burn\Burn

Edited by Yzöwl
Post updated due to performed testing.
Posted

I see I see. Specifically I was looking at your lines that look like this:

setup.ini, group4,,"""Restoration"",""""""%16422%\Standalone\Restoration\Restoration.exe"""""""

Specifically """"""%16422%\Standalone\Restoration\Restoration.exe"""""". Are the extra quotes to account for the spaces in %16422%?

Could you explain the functionality of your runonce reg add commands? Particularly the %REG%\045 key and the significance of rundll32 setupapi,InstallHinfSection Shortcuts 128. Would I be correct to assume %REG%\045 is similar to the common DIRID listings? My imagination suggests that rundll32, setupapi,InstallHingSection are the necessary components to integrate the contents of shortcuts.inf to setup.ini. I'm at a loss for what the Shortcuts 128 portion of this reg add command does, could you explain this as well?

Sorry, lots of questions...

A.) Why so many quotes in """"""%16422%\Standalone\Restoration\Restoration.exe""""""?

B.) Is %REG%\045 similar in function to common DIRID shortcuts?

C.) How does rundll32 setupapi,InstallHinfSection Shortcuts 128 effect the reg add command? I understand that because this information follows /d it is the data portion of the key...but how does that help integrate shortcuts.inf into setup.ini?

I still haven't successfully automated my desktop shortcuts using an INF...but with your help in understanding the foundation for this method I'm confident I can get this working the way you intended.

Posted

I have updated my previous post in order to help answer A.)

I'm not sure what you mean in B.), (%REG%\045 doesn't exist), please clarify.

For C.), that is the command-line which performs the install/invokation of the inf file.

Posted

For that I recommend you read 'The Guide'.

Incidentally, because you are running a minimum of Windows XP sp2, (Office 2007 minimum requirement), here is an alternative inf method for creating your shortcuts.

[Version]
Signature = $Windows NT$

[DefaultInstall]
ProfileItems = AddBgi, AddWmv, AddDoc, AddPps, AddXls

[AddBgi]
Name = bginfo, 1
CmdLine = 24, , bginfo.exe default.bgi /timer:0 /nolicprompt /silent
SubDir = Startup

[AddWmv]
Name = Windows Media Player, 8, 16409
CmdLine = 16422, Windows Media Player, wmplayer.exe

[AddDoc]
Name = Microsoft Word, 8, 16409
CmdLine = 16422, Microsoft Office\Office12, winword.exe

[AddPps]
Name = Microsoft Powerpoint, 8, 16409
CmdLine = 16422, Microsoft Office\Office12, powerpnt.exe

[AddXls]
Name = Microsoft Excel, 8, 16409
CmdLine = 16422, Microsoft Office\Office12, excel.exe

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