jinkazama Posted February 15, 2013 Posted February 15, 2013 (edited) 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 February 16, 2013 by jinkazama
jinkazama Posted February 15, 2013 Author Posted February 15, 2013 (edited) 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 February 25, 2013 by jinkazama
Tripredacus Posted February 15, 2013 Posted February 15, 2013 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" )
jaclaz Posted February 15, 2013 Posted February 15, 2013 Or get nircmd:http://www.nirsoft.net/utils/nircmd.htmlWhich is also useful for a ton other tasks.Which OS?If Vista or 7, check this also:http://www.techrepublic.com/blog/window-on-windows/how-do-i-copy-shortcuts-to-the-all-users-folders-in-vista-or-windows-7/1857jaclaz
radix Posted February 15, 2013 Posted February 15, 2013 (edited) 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\DesktopAutoIt 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.infinstall.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 X86IF EXIST %SystemRoot%\SysWOW64 GOTO X64:: 32 bit:X86::Create All Users Desktop icons for Word 2003 and Excel 2003 on 32 bit operating systemsstart 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 systemsstart rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x64.inf,,1:ENDEXITcreate_shortcut_x86.inf content:[Version]Signature=$Windows NT$[DefaultInstall]ProfileItems=1IconItemAddProfileItems=2IconItemAdd[1IconItemAdd]; All Users Desktop icon for MSO Word 2003Name = "Word 2003", 0x0000008, 16409CmdLine = 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 2003Name = "Excel 2003", 0x0000008, 16409CmdLine = 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=1IconItemAddProfileItems=2IconItemAdd[1IconItemAdd]; All Users Desktop icon for MSO Word 2003Name = "Word 2003", 0x0000008, 16409CmdLine = 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 2003Name = "Excel 2003", 0x0000008, 16409CmdLine = 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 February 16, 2013 by radix
jinkazama Posted February 15, 2013 Author Posted February 15, 2013 I need it for all OS, Windows XP, Vista, 7 and 8
jinkazama Posted February 24, 2013 Author Posted February 24, 2013 @radixi've create same script for Word and Excel 2007 but it doesn't workCan you check it for me?Thank youinstall.cmd@ECHO OFF:: Check the operating system type (32 bit or 64 bit)IF NOT EXIST %SystemRoot%\SysWOW64 GOTO X86IF EXIST %SystemRoot%\SysWOW64 GOTO X64:: 32 bit:X86::Create All Users Desktop icons for Word 2007 and Excel 2007 on 32 bit operating systemsstart 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 systemsstart rundll32.exe advpack.dll,LaunchINFSection create_shortcut_x64.inf,,1:ENDEXITcreate_shortcut_x86.inf[Version]Signature=$Windows NT$[DefaultInstall]ProfileItems=1IconItemAddProfileItems=2IconItemAdd[1IconItemAdd]; All Users Desktop icon for MSO Word 2007Name = "Microsoft Office Word 2007", 0x0000008, 16409CmdLine = 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 2007Name = "Microsoft Office Excel 2007", 0x0000008, 16409CmdLine = 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=1IconItemAddProfileItems=2IconItemAdd[1IconItemAdd]; All Users Desktop icon for MSO Word 2007Name = "Microsoft Office Word 2007", 0x0000008, 16409CmdLine = 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 2007Name = "Microsoft Office Excel 2007", 0x0000008, 16409CmdLine = 16426,"Microsoft Office\Office12","EXCEL.EXE"WorkingDir = 16426,"Microsoft Office\Office12"InfoTip = "Easily discover, visualize, and share insights from your data."
Geej Posted February 25, 2013 Posted February 25, 2013 (edited) 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,25CmdLine = 16422,Microsoft Office\Office12,WINWORD.EXEWorkingDir = 16422,Microsoft Office\Office12InfoTip ="Create and edit professional-looking documents such as letters, papers, reports, and booklets by using Microsoft Office Word."[ExcelSC]Name = Excel 2007,0x8,25CmdLine = 16422,Microsoft Office\Office12,EXCEL.EXEWorkingDir = 16422,Microsoft Office\Office12InfoTip = "Perform calculations, analyze information, and visualize data in spreadsheets by using Microsoft Office Excel."[WordSC64]Name =Word 2007,0x8,25CmdLine = 16426,Microsoft Office\Office12,WINWORD.EXEWorkingDir = 16426,Microsoft Office\Office12InfoTip ="Create and edit professional-looking documents such as letters, papers, reports, and booklets by using Microsoft Office Word."[ExcelSC64]Name = Excel 2007,0x8,25CmdLine = 16426,Microsoft Office\Office12,EXCEL.EXEWorkingDir = 16426,Microsoft Office\Office12InfoTip = "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 February 25, 2013 by Geej
Geej Posted February 26, 2013 Posted February 26, 2013 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
DosProbie Posted February 26, 2013 Posted February 26, 2013 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 youWhen 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..
radix Posted March 3, 2013 Posted March 3, 2013 (edited) @jinkazamaYour 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.@GeejYour 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 March 3, 2013 by radix
DosProbie Posted March 3, 2013 Posted March 3, 2013 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 youJinkazama, 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.. [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.13Dim 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]
jinkazama Posted March 3, 2013 Author Posted March 3, 2013 @jinkazamaYour 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.@GeejYour 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
Geej Posted March 4, 2013 Posted March 4, 2013 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
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now