• Project shortcut variable for current drive

    Home » Forums » AskWoody support » Windows » Windows – other » Project shortcut variable for current drive

    Author
    Topic
    #428965

    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…

    Viewing 0 reply threads
    Author
    Replies
    • #997886

      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——-

      • #997892

        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.

      • #997893

        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!

    Viewing 0 reply threads
    Reply To: Project shortcut variable for current drive

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: