User Tools

Site Tools


script:powershell:icon

PowerShell : Créer des icones

Il est possible de créer des icones avec un script PowerShell

This program demonstrates how to use the Windows Script Host to create a shortcut on the Windows Desktop. In order to run this example, you must have the Windows Script Host installed on your computer. To run one of these examples, copy the code below into a new program file and run it. Example 1 WshShell = CreateObject(“Wscript.shell”) strDesktop = WshShell.SpecialFolders(“Desktop”) oMyShortcut = WshShell.CreateShortcut(strDesktop + “\Sample.lnk”) oMyShortcut.WindowStyle = 3 &&Maximized 7=Minimized 4=Normal oMyShortcut.IconLocation = “C:\myicon.ico” OMyShortcut.TargetPath = “%windir%\notepad.exe” oMyShortCut.Hotkey = “ALT+CTRL+F” oMyShortCut.Save Example 2 (Add a command line argument) WshShell = CreateObject(“WScript.Shell”) strDesktop = WshShell.SpecialFolders(“Desktop”) oMyShortCut= WshShell.CreateShortcut(strDesktop+“\Foxtest.lnk”) oMyShortCut.WindowStyle = 7 &&Minimized 0=Maximized 4=Normal oMyShortcut.IconLocation = home()+“wizards\graphics\builder.ico” oMyShortCut.TargetPath = “c:\Program Files\Microsoft Visual Studio\VFP98\vfp6.exe” oMyShortCut.Arguments = '-c'+'“'+Home()+'config.fpw'+'”' oMyShortCut.WorkingDirectory = “c:\” oMyShortCut.Save Note Depending on the version of Visual FoxPro that you are using, you may need to change the name and the path of the Visual FoxPro executable in Example 2. Example 3 (Add a URL Shortcut to the desktop) WshShell = CreateObject(“WScript.Shell”) strDesktop = WshShell.SpecialFolders(“Desktop”) oUrlLink = WshShell.CreateShortcut(strDesktop+“\Microsoft Web Site.URL”) oUrlLink.TargetPath = “http://www.microsoft.com” oUrlLink.Save Note For the shortcut to be created, valid parameters must be passed for all methods. No error appears if one of the parameters is incorrect.

script/powershell/icon.txt · Last modified: 2020/11/25 14:10 by admin