home *** CD-ROM | disk | FTP | other *** search
- Option Explicit
-
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' This script shows how to use VBScript and the scripting host
- ' to create a desktop shortcut to Notepad and set hotkeys for it
- '
- ' Requirements: VBScript version 5
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 'Create some global variables
- Dim sMsg, sTitle, iResponse 'For message box
- Dim oShell, sPath, oShortcut 'For creating shortcut
- Dim sWindows, sNotepad 'Path to Windows directory and Notepad
-
- sMsg = "Do you want to create a shortcut for " & _
- "Notepad on your desktop?"
- sTitle = "Creating Shortcut"
- iResponse = MsgBox(sMsg, vbOKCancel + vbInformation, sTitle)
- If iResponse = vbCancel then
- Wscript.Echo "Ending without creating shortcut"
- WScript.Quit
- End If
-
- 'Create a shell object and use it to create a shortcut
- Set oShell = WScript.CreateObject("WScript.Shell")
- sPath = oShell.SpecialFolders("Desktop")
- Set oShortcut = oShell.CreateShortcut(sPath & "\New Notepad.lnk")
- sWindows = oShell.ExpandEnvironmentStrings("%windir%")
- sNotepad = sWindows & "\Notepad.exe"
- oShortcut.TargetPath = sNotepad
- oShortcut.WorkingDirectory = oShell.SpecialFolders("MyDocuments")
- oShortcut.WindowStyle = 1
- oShortcut.IconLocation = sNotepad & ",0"
- oShortcut.Hotkey = "ALT+CTRL+N"
- oShortcut.Description = "Shortcut created by a VBScript Program"
- oShortcut.Save
-
- Set oShortcut = Nothing
- WScript.Echo "New shortcut to Notepad has been created"
- WScript.Quit
-
-