.CreateShortcut - VBScript
Overview
.CreateShortcut
creates a shortcut to a specified file, folder, or website on the user’s desktop. This command can streamline access to applications, documents, or websites. It’s commonly used to organize and quickly launch frequently used programs or files.
Syntax
CreateShortcut(TargetFile, ShortcutFile)
Parameters:
- TargetFile: The path to the file, folder, or website to create a shortcut for.
- ShortcutFile: The path and filename of the shortcut to be created.
Options/Flags
None
Examples
Create a shortcut to a file:
CreateShortcut "C:\My Documents\test.txt", "C:\Users\John\Desktop\test.lnk"
Create a shortcut to a folder:
CreateShortcut "C:\My Documents", "C:\Users\John\Desktop\My Documents.lnk"
Create a shortcut to a website:
CreateShortcut "https://www.example.com", "C:\Users\John\Desktop\example.lnk"
Common Issues
Shortcut not visible: Ensure that the target file or website is accessible. Check the file path or URL and try again.
Permission issues: Running the script as an administrator may be necessary to create shortcuts on the desktop.
Integration
.CreateShortcut
can be combined with other commands for advanced tasks, such as:
- Deleting shortcuts: Use
.DeleteFile
to remove shortcuts created earlier. - Customizing shortcuts: Modify shortcut properties like icon, description, and working directory using
.IWshShortcut
object.
Related Commands
.FileExists
.IWshShell
.IWshShortcut