Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Best way to create shortcuts silently

- - - - -

  • Please log in to reply
15 replies to this topic

#1
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag
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, 16 February 2013 - 02:22 AM.

ubrezet.png
userbardriverpackteam3nv0.jpg



How to remove advertisement from MSFN

#2
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
I usually use this for this kind of task.

#3
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag
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, 25 February 2013 - 04:42 PM.

ubrezet.png
userbardriverpackteam3nv0.jpg


#4
Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Super Moderator
  • 9,807 posts
  • OS:Server 2012
  • Country: Country Flag

Donator

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" )

MSFN RULES | GimageX HTA for PE 3-5 | lol probloms
msfn2_zpsc37c7153.jpg

#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,387 posts
  • OS:none specified
  • Country: Country Flag
Or get nircmd:
http://www.nirsoft.n...ils/nircmd.html

Which is also useful for a ton other tasks.

Which OS?
If Vista :ph34r: or 7, check this also:
http://www.techrepub...-windows-7/1857

jaclaz

#6
radix

radix

    Friend of MSFN

  • Member
  • PipPipPipPipPip
  • 738 posts
  • OS:Windows 8 x64
  • Country: Country Flag
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, 16 February 2013 - 09:53 AM.


#7
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag
I need it for all OS, Windows XP, Vista, 7 and 8

ubrezet.png
userbardriverpackteam3nv0.jpg


#8
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag
@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."

ubrezet.png
userbardriverpackteam3nv0.jpg


#9
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • OS:XP Pro x86
  • Country: Country Flag
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, 24 February 2013 - 06:46 PM.


#10
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • OS:XP Pro x86
  • Country: Country Flag
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

#11
DosProbie

DosProbie

    Friend of MSFN

  • MSFN Sponsor
  • 739 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag

Donator

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

#12
radix

radix

    Friend of MSFN

  • Member
  • PipPipPipPipPip
  • 738 posts
  • OS:Windows 8 x64
  • Country: Country Flag
@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, 03 March 2013 - 06:07 AM.


#13
DosProbie

DosProbie

    Friend of MSFN

  • MSFN Sponsor
  • 739 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag

Donator

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.. Posted Image
[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
][/code]



#14
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag

@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

ubrezet.png
userbardriverpackteam3nv0.jpg


#15
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • OS:XP Pro x86
  • Country: Country Flag
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

#16
jinkazama

jinkazama

    Member

  • Member
  • PipPip
  • 201 posts
  • OS:Windows 8 x64
  • Country: Country Flag
hi Geej, i'm trying all posted methods, i'll feedback about tests :)

ubrezet.png
userbardriverpackteam3nv0.jpg





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN