Create a generic shortcut on USB device

Author Message
Trader Horn

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 12/15/2009
  • Location: Thailand
  • Status: offline
Create a generic shortcut on USB device Tuesday, December 15, 2009 4:09 PM (permalink)
0
There was an old thread here asking for a VBScript that would allow a shortcut on a USB root drive to target an executable in any folder or subfolder where the root drive letter may change on a different computer. I hope this fits the bill:

'* NAME of Script: shortcutUSB.adm (note, not vbs please!)
'* Used as the target for a local (root directory) USB shortcut. Locate this
'* script inside the folder containing the executable to be run (AnyFolder) and
'* create a shortcut in the USB root with 'target' as follows (use the single
'* quote character (') to insert any double-quotes (") into any <arguments> ):
'* wscript.exe //e:vbscript AnyFolder\shortcutUSB.adm /file:"<executable>"
'* /args:"<arguments>"
'* Right-click the shortcut, select 'Properties' and do the following to create
'* a new icon:
'* Clear the 'Start In' box and enter '%systemRoot%\system32\SHELL32.dll' in the
'* 'Change Icon' (Browse...) dialog box; select the icon, then 'OK' and 'Apply'.
'* Example: wscript.exe //e:vbscript AnyFolder\shortcutUSB.adm /File:"abc.exe"
'* /args:"'Documents And Settings' 'My Data'"
'* --> Note the double-quotes surrounding the multiple arguments <--
'* The author can be contacted via www.SeaStarDevelopment.Bravehost.com

On Error Resume Next
Const NORMAL_WINDOW = 1
Set colNamedArgs = Wscript.Arguments.Named
If colNamedArgs.Exists("File") Then
   strFile = colNamedArgs.Item("File")
   strFile = Replace(Wscript.ScriptFullName,Wscript.ScriptName,strFile)
   strArgs = colNamedArgs.Item("Args")
   strArgs = Replace(strArgs,"'",Chr(34))
   Set Shell  = CreateObject("Wscript.Shell")
   strCommand = Chr(34) & strFile & Chr(34) & " " & strArgs
   Shell.Run strCommand, NORMAL_WINDOW
Else
   Wscript.Echo "Error: no local target for shortcut."
End If





 
#1

    Online Bookmarks Sharing: Share/Bookmark

    Jump to:

    Current active users

    There are 0 members and 1 guests.

    Icon Legend and Permission

    • New Messages
    • No New Messages
    • Hot Topic w/ New Messages
    • Hot Topic w/o New Messages
    • Locked w/ New Messages
    • Locked w/o New Messages
    • Read Message
    • Post New Thread
    • Reply to message
    • Post New Poll
    • Submit Vote
    • Post reward post
    • Delete my own posts
    • Delete my own threads
    • Rate post

    2000-2012 ASPPlayground.NET Forum Version 3.9