jinkazama

Best way to create shortcuts silently

16 posts in this topic

Does anyone know how to create a desktop shortcut to an executable using a command line/batch or reg file?

I need it to solve desktop shortcuts for silent installer withous link creation switch like trojan remover.

Or for example, can i make a file to create shortcuts on desktop for word2003 and Excel 2003 after installing Office 2003 Word2007 and Excel 2007 after installing Office 2007?

Thank you

Edited by jinkazama
0

Share this post


Link to post
Share on other sites

Thank you allen2, i'll try shortcut 1.11, only a question, how can i create a link on all user desktop?

An example for skype:

shortcut.exe /F:"%allusersprofile%\Desktop\Testskype.lnk" /a:c /t:"%ProgramFiles(x86)%\Skype\Phone\Skype.exe"

How can i run it silently?

Edited by jinkazama
0

Share this post


Link to post
Share on other sites

Alternatively, here is how to do it using AutoIT:

FileCreateShortcut ( "c:\program files\folder\file.exe" , "c:\users\public\desktop\File Name.lnk" , "c:\program files\workingdir" , "" , "Description" , "c:\program files\folder\iconfile.ico" )

0

Share this post


Link to post
Share on other sites

You should use inf method or AutoIt, because these methods use dir id's (inf) or macros for folders (AutoIt), for example @DesktopCommonDir instead of C:\Users\Public\Desktop

AutoIt method (on the top of .au3 file, you can add command to install Office 2003 silently):

FileCreateShortcut(@ProgramFilesDir & "\Microsoft Office\Office11\WINWORD.EXE", @DesktopCommonDir & "\Word 2003.lnk", @ProgramFilesDir & "\Microsoft Office\Office11", "", "Create beautiful documents, easily work with others, and enjoy the read.")
FileCreateShortcut(@ProgramFilesDir & "\Microsoft Office\Office11\EXCEL.EXE", @DesktopCommonDir & "\Excel 2003.lnk", @ProgramFilesDir & "\Microsoft Office\Office11", "", "Easily discover, visualize, and share insights from your data.")

Inf method:

Use 3 files: install.cmd, create_shortcut_x86.inf and create_shortcut_x64.inf

install.cmd content (on the top of install.cmd file, you can add command to install Office 2003 silently):

@ECHO OFF
:: Check the operating system type (32 bit or 64 bit)
IF NOT EXIST %SystemRoot%\SysWOW64 GOTO X86
IF EXIST %SystemRoot%\SysWOW64 GOTO X64
:: 32 bit
:X86
::Create All Users Desktop icons for Word 2003 and Excel 2003 on 32 bit operating systems
start rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x86.inf,,1
:: 64 bit
:X64
::Create All Users Desktop icons for Word 2003 and Excel 2003 on 64 bit operating systems
start rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x64.inf,,1
:END
EXIT

create_shortcut_x86.inf content:

[Version]
Signature=$Windows NT$

[DefaultInstall]
ProfileItems=1IconItemAdd
ProfileItems=2IconItemAdd

[1IconItemAdd]
; All Users Desktop icon for MSO Word 2003
Name = "Word 2003", 0x0000008, 16409
CmdLine = 16422,"Microsoft Office\Office11","WINWORD.EXE"
WorkingDir = 16422,"Microsoft Office\Office11"
InfoTip = "Create beautiful documents, easily work with others, and enjoy the read."

[2IconItemAdd]
; All Users Desktop icon for MSO Excel 2003
Name = "Excel 2003", 0x0000008, 16409
CmdLine = 16422,"Microsoft Office\Office11","EXCEL.EXE"
WorkingDir = 16422,"Microsoft Office\Office11"
InfoTip = "Easily discover, visualize, and share insights from your data."

create_shortcut_x64.inf content:

[Version]
Signature=$Windows NT$

[DefaultInstall]
ProfileItems=1IconItemAdd
ProfileItems=2IconItemAdd

[1IconItemAdd]
; All Users Desktop icon for MSO Word 2003
Name = "Word 2003", 0x0000008, 16409
CmdLine = 16426,"Microsoft Office\Office11","WINWORD.EXE"
WorkingDir = 16426,"Microsoft Office\Office11"
InfoTip = "Create beautiful documents, easily work with others, and enjoy the read."

[2IconItemAdd]
; All Users Desktop icon for MSO Excel 2003
Name = "Excel 2003", 0x0000008, 16409
CmdLine = 16426,"Microsoft Office\Office11","EXCEL.EXE"
WorkingDir = 16426,"Microsoft Office\Office11"
InfoTip = "Easily discover, visualize, and share insights from your data."

More info regarding shortcut creation using inf here

Edited by radix
0

Share this post


Link to post
Share on other sites

I need it for all OS, Windows XP, Vista, 7 and 8

0

Share this post


Link to post
Share on other sites

@radix

i've create same script for Word and Excel 2007 but it doesn't work

Can you check it for me?

Thank you

install.cmd


@ECHO OFF
:: Check the operating system type (32 bit or 64 bit)
IF NOT EXIST %SystemRoot%\SysWOW64 GOTO X86
IF EXIST %SystemRoot%\SysWOW64 GOTO X64
:: 32 bit
:X86
::Create All Users Desktop icons for Word 2007 and Excel 2007 on 32 bit operating systems
start rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x86.inf,,1
:: 64 bit
:X64
::Create All Users Desktop icons for Word 2007 and Excel 2007 on 64 bit operating systems
start rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x64.inf,,1
:END
EXIT

create_shortcut_x86.inf


[Version]
Signature=$Windows NT$

[DefaultInstall]
ProfileItems=1IconItemAdd
ProfileItems=2IconItemAdd

[1IconItemAdd]
; All Users Desktop icon for MSO Word 2007
Name = "Microsoft Office Word 2007", 0x0000008, 16409
CmdLine = 16422,"Microsoft Office\Office12","WINWORD.EXE"
WorkingDir = 16422,"Microsoft Office\Office12"
InfoTip = "Create beautiful documents, easily work with others, and enjoy the read."

[2IconItemAdd]
; All Users Desktop icon for MSO Excel 2007
Name = "Microsoft Office Excel 2007", 0x0000008, 16409
CmdLine = 16422,"Microsoft Office\Office12","EXCEL.EXE"
WorkingDir = 16422,"Microsoft Office\Office12"
InfoTip = "Easily discover, visualize, and share insights from your data."

create_shortcut_x64.inf


[Version]
Signature=$Windows NT$

[DefaultInstall]
ProfileItems=1IconItemAdd
ProfileItems=2IconItemAdd

[1IconItemAdd]
; All Users Desktop icon for MSO Word 2007
Name = "Microsoft Office Word 2007", 0x0000008, 16409
CmdLine = 16426,"Microsoft Office\Office12","WINWORD.EXE"
WorkingDir = 16426,"Microsoft Office\Office12"
InfoTip = "Create beautiful documents, easily work with others, and enjoy the read."

[2IconItemAdd]
; All Users Desktop icon for MSO Excel 2007
Name = "Microsoft Office Excel 2007", 0x0000008, 16409
CmdLine = 16426,"Microsoft Office\Office12","EXCEL.EXE"
WorkingDir = 16426,"Microsoft Office\Office12"
InfoTip = "Easily discover, visualize, and share insights from your data."

0

Share this post


Link to post
Share on other sites

Here is my MSOfficeSc.inf for Word & excel 2007 (works for x86 & x64 within 1 inf)

Command line usage is at the end of inf

; Word & Excel 2007 Shortcut on all users desktop

[Version]
Signature=$Windows NT$

[DefaultInstall]
RegisterDLLs=Start.Register

[Start.Register]
11,,rundll32.exe,,,"advpack.dll,LaunchINFSection %1%\%infname%.inf,Install"

[Install.ntx86]
ProfileItems=WordSC, ExcelSC

[Install.ntamd64]
ProfileItems=WordSC64, ExcelSC64

[WordSC]
Name =Word 2007,0x8,25
CmdLine = 16422,Microsoft Office\Office12,WINWORD.EXE
WorkingDir = 16422,Microsoft Office\Office12
InfoTip ="Create and edit professional-looking documents such as letters, papers, reports, and booklets by using Microsoft Office Word."

[ExcelSC]
Name = Excel 2007,0x8,25
CmdLine = 16422,Microsoft Office\Office12,EXCEL.EXE
WorkingDir = 16422,Microsoft Office\Office12
InfoTip = "Perform calculations, analyze information, and visualize data in spreadsheets by using Microsoft Office Excel."

[WordSC64]
Name =Word 2007,0x8,25
CmdLine = 16426,Microsoft Office\Office12,WINWORD.EXE
WorkingDir = 16426,Microsoft Office\Office12
InfoTip ="Create and edit professional-looking documents such as letters, papers, reports, and booklets by using Microsoft Office Word."

[ExcelSC64]
Name = Excel 2007,0x8,25
CmdLine = 16426,Microsoft Office\Office12,EXCEL.EXE
WorkingDir = 16426,Microsoft Office\Office12
InfoTip = "Perform calculations, analyze information, and visualize data in spreadsheets by using Microsoft Office Excel."

[Strings]
Infname=MSOfficeSc

[commandline]
rundll32.exe advpack.dll,LaunchINFSection MSOfficeSc.inf,install

Edited by Geej
0

Share this post


Link to post
Share on other sites

Come to think of it, I think the best way to create shortcut silently is to use OCT 2007 (office customization tool), if you are using it.

It allows to create desktop shortcut. Better than any script, IMHO. During uninstall, at least it is able to remove it.

For reference, scroll (3/4 down the page) to 'Add/Modify Shortcut Entry dialog box' -> 'Location' for various shortcut location.

Best regards

0

Share this post


Link to post
Share on other sites

Does anyone know how to create a desktop shortcut to an executable using a command line/batch or reg file?

I need it to solve desktop shortcuts for silent installer withous link creation switch like trojan remover.

Or for example, can i make a file to create shortcuts on desktop for word2003 and Excel 2003 after installing Office 2003 Word2007 and Excel 2007 after installing Office 2007?

Thank you

When I do my O2K7 Install and now O2K10 rather than have shortcuts to the desktop I have then auto install to the taskbar for a cleaner look.. from a reg file and vbs file..

0

Share this post


Link to post
Share on other sites

@jinkazama

Your samples from the post #8 will not work, because you have installed a 64 bit version of Office 2007 under a 64 bit version of Windows. In this case change 16426 with 16422 in create_shortcut_x64.inf and make sure that you always install Office 2007 x64 or laterunder a 64 bit OS.

@Geej

Your script will not work with Office 2007 x64 or later under 64 bit Windows due to the same reason explained above.

Edit: jinkazama, if you want to use a simpler method (a single AutoIt script for all install process and shortcut creation), I can post one.

Edited by radix
0

Share this post


Link to post
Share on other sites

Does anyone know how to create a desktop shortcut to an executable using a command line/batch or reg file?

I need it to solve desktop shortcuts for silent installer withous link creation switch like trojan remover.

Or for example, can i make a file to create shortcuts on desktop for word2003 and Excel 2003 after installing Office 2003 Word2007 and Excel 2007 after installing Office 2007?

Thank you

Jinkazama,

This is a .vbs script that I use when doing silent install, I set the path normally to the Taskbar (Don't like my desktop cluttered with shortcuts)

but I adjusted this to the desktop for you... I run it from my FinalRun.cmd batch file with the following command:

cscript //nologo "%~dp0AddShortcuts.vbs" or you can try "%~dp0AddShortcuts.vbs"

DosProbie.. biggrin.gif

[code' Auto Adds Shortcut's to Desktop

' AddShortcuts.vbs - DosProbie.2013

' Pin Shortcuts To Desktop - Win7 or Win8 64-bit

' Note: Revise the first line "objShortCut = Shell" PATH FOR SHORTCUT AS NEEDED!

' Revised: 03.03.13

Dim Act,colEnvironmentVariables, objShortCut, Shell

Set Shell = CreateObject("WScript.Shell")

Set colEnvironmentVariables = Shell.Environment("Volatile")

Set Act = CreateObject("Wscript.Shell")

'Excel 2007

Set objShortCut = Shell.CreateShortcut(Act.ExpandEnvironmentStrings("%userprofile%\desktop\Microsoft Office Excel 2007.lnk"))

objShortCut.TargetPath = Act.ExpandEnvironmentStrings("%programfiles(x86)%\Microsoft Office\Office12\Excel.exe")

objShortCut.Arguments = " /prefetch:1"

objShortCut.Description = "Essential software suite for home computer users with Office 2007."

objShortCut.Save

'Word 2007

Set objShortCut = Shell.CreateShortcut(Act.ExpandEnvironmentStrings("%userprofile%\desktop\Microsoft Office Word 2007.lnk"))

objShortCut.TargetPath = Act.ExpandEnvironmentStrings("%programfiles(x86)%\Microsoft Office\Office12\WINWORD.EXE")

objShortCut.Arguments = " /prefetch:1"

objShortCut.Description = "Essential software suite for home computer users with Office 2007."

objShortCut.Save

'WMP 12.0

'Set objShortCut = Shell.CreateShortcut(Act.ExpandEnvironmentStrings("%userprofile%\desktop\windows media player.lnk"))

'objShortCut.TargetPath = Act.ExpandEnvironmentStrings("%programfiles(x86)%\windows media player\wmplayer.exe")

'objShortCut.Arguments = " /prefetch:1"

'objShortCut.Description = "Play digital media including music, videos, CDs, and DVDs."

'objShortCut.Save

]

0

Share this post


Link to post
Share on other sites

@jinkazama

Your samples from the post #8 will not work, because you have installed a 64 bit version of Office 2007 under a 64 bit version of Windows. In this case change 16426 with 16422 in create_shortcut_x64.inf and make sure that you always install Office 2007 x64 or laterunder a 64 bit OS.

@Geej

Your script will not work with Office 2007 x64 or later under 64 bit Windows due to the same reason explained above.

Edit: jinkazama, if you want to use a simpler method (a single AutoIt script for all install process and shortcut creation), I can post one.

radix, i have office 2007 32bit installed on Windows x64

0

Share this post


Link to post
Share on other sites

Hi jinkazama

Does my inf works for you?

What have you tried so far? If doesn't work for you, can you provide more detail...

Cheers

0

Share this post


Link to post
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.