' Definie shell objectSet objWSHShell = WScript.CreateObject("Wscript.Shell")strDesktop = objWSHShell.SpecialFolders("Desktop")' Copy the icon file to windowsSet objFSO = CreateObject("Scripting.FileSystemObject")Set objFileCopy = objFSO.GetFile( objWSHShell.CurrentDirectory&"\icon.ico")objFileCopy.Copy ("C:\WINDOWS\system32\")' Define link properties and create linkstrShortcutName = "Log In" ' Shortcut Name - Edit for the wanted namestrShortcutPath = "http://thesystem.com/Login.aspx" ' Link URL - Edit to the wanted URLstrIconPath = "C:\WINDOWS\system32\icon.ico"Set objShortcut = objWSHShell.CreateShortcut(strDesktop & "\" & strShortcutName & ".lnk")objShortcut.TargetPath=strShortcutPathobjShortcut.IconLocation=strIconPathobjShortcut.Save' Quit ScriptWScript.Quit
But later the user access rights has been limited and were blocked accessing system folder, the link creator didn't created the link with supplied icon file. As the icon file is copied to the system folder. So the updated script would not use supplied icon file, but make use of existing system icon.
' Definie shell object
Set objWSHShell = WScript.CreateObject("Wscript.Shell")
strDesktop = objWSHShell.SpecialFolders("Desktop")
' Define link properties and create link
strShortcutName = "LogIn" ' Shortcut Name - Edit for the wanted name
strShortcutPath = "http://thesystem.com/Login.aspx" ' Link URL - Edit to the wanted URL
strIconPath = "c:\windows\system32\shell32.dll,44"
Set objShortcut = objWSHShell.CreateShortcut(strDesktop & "\" & strShortcutName & ".lnk")
objShortcut.TargetPath=strShortcutPath
objShortcut.IconLocation=strIconPath
objShortcut.Save
' Quit Script
WScript.Quit
Now the icon shown from system.
Comments
Post a Comment