home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / wsh.cab / shortcut.vbs < prev    next >
Text File  |  1997-09-16  |  2KB  |  60 lines

  1. ' Windows Script Host Sample Script
  2. '
  3. ' ------------------------------------------------------------------------
  4. '               Copyright (C) 1996-1997 Microsoft Corporation
  5. '
  6. ' You have a royalty-free right to use, modify, reproduce and distribute
  7. ' the Sample Application Files (and/or any modified version) in any way
  8. ' you find useful, provided that you agree that Microsoft has no warranty,
  9. ' obligations or liability for any Sample Application Files.
  10. ' ------------------------------------------------------------------------
  11.  
  12.  
  13. ' This sample demonstrates how to use the WSHShell object to create a shortcut
  14. ' on the desktop.
  15.  
  16. L_Welcome_MsgBox_Message_Text   = "This script will create a shortcut to Notepad on your desktop."
  17. L_Welcome_MsgBox_Title_Text     = "Windows Scripting Host Sample"
  18. Call Welcome()
  19.  
  20. ' ********************************************************************************
  21. ' *
  22. ' * Shortcut related methods.
  23. ' *
  24.  
  25. Dim WSHShell
  26. Set WSHShell = WScript.CreateObject("WScript.Shell")
  27.  
  28.  
  29. Dim MyShortcut, MyDesktop, DesktopPath
  30.  
  31. ' Read desktop path using WshSpecialFolders object
  32. DesktopPath = WSHShell.SpecialFolders("Desktop")
  33.  
  34. ' Create a shortcut object on the desktop
  35. Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\Shortcut to notepad.lnk")
  36.  
  37. ' Set shortcut object properties and save it
  38. MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe")
  39. MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%")
  40. MyShortcut.WindowStyle = 4
  41. MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe, 0")
  42. MyShortcut.Save
  43.  
  44. WScript.Echo "A shortcut to Notepad now exists on your Desktop."
  45.  
  46. ' ********************************************************************************
  47. ' *
  48. ' * Welcome
  49. ' *
  50. Sub Welcome()
  51.     Dim intDoIt
  52.  
  53.     intDoIt =  MsgBox(L_Welcome_MsgBox_Message_Text,    _
  54.                       vbOKCancel + vbInformation,       _
  55.                       L_Welcome_MsgBox_Title_Text )
  56.     If intDoIt = vbCancel Then
  57.         WScript.Quit
  58.     End If
  59. End Sub
  60.