Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Project shortcut variable for current drive

    Help. I seem to always get myself into what should be simple situations more complicated...

    I would like to put a program on a USB flash drive. It runs fine from there. The only catch is that I have to navigate to the EXE buried in folders. I would like to put a shortcut on the USB flash drive, but it needs to find that drive no matter what drive letter it becomes. (I will be plugging this USB drive into different computers and have no control over the letter assigned.) When I create a normal shortcut, it puts in the current drive letter. How do I say "the drive you are on right now" or such?

    In batch files we could use .whatever or ..whatever but that does not seem to work in shortcuts. I seem to remember some %drive% variables, but can't find a list of them...
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  2. #2
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Project shortcut variable for current drive

    It's so easy! Create a BAT or VBS file in the root of your flash drive.

    Say, your EXE file is in Folder1SubFolder2One more Folder 3File to run.exe and you need -quiet switch

    ------Example of BAT file----
    @ECHO OFF
    CD Folder1
    CD "subfolder2"
    CD "one more folder 3"
    "File to run.exe" -quiet
    --------End of BAT file----

    -------Sample of VBS file----
    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")
    WSHShell.Run(".Folder1SubFolder2One more Folder 3File to run.exe" -quiet)
    ------End of VBS file----

    If you are running Windows XP, you can also put Autorun.inf file to run your EXE file when drive is inserted:

    ---Example of AUTORUN.INF file------
    [autorun]
    OPEN=batfile.bat
    ------End of AUTORUN.INF file--------

    ----Another example------
    [autorun]
    OPEN=wscript.exe myvbsfile.vbs
    ------End of example-------

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Project shortcut variable for current drive

    When I try that BAT file, it flashes a DOS window then is gone. I can't see what the error (if there is one) is.

    Logically this makes sense -- I'm not sure what is wrong.
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Chicago, Illinois, USA
    Posts
    177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Project shortcut variable for current drive

    Oh wait. Major brain fart.

    This works:

    ---BAT start---
    @ECHO OFF
    CD firstdir
    CD secondsubdir
    blah.exe
    ---BAT end---

    The key was NOT using the leading symbol.

    Thanks!
    <font color=blue>Eric A. Spanitz</font color=blue>
    Quality, Project, Management * Training * Consulting
    http://www.spanitz.com * http://www.synergest.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •