Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Problem with batch script designed to get drive letter  (Read 2743 times)

0 Members and 1 Guest are viewing this topic.

yocool13

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Other
    Problem with batch script designed to get drive letter
    « on: December 14, 2016, 12:58:30 PM »
    I have problems with the script I got from this topic which is very old: http://www.computerhope.com/forum/index.php?topic=136690.0
    Code: [Select]
    for /f "tokens=3 delims= " %%A in ('echo list volume ^| diskpart ^| findstr "X"') do (
    set D=%%A
    )
    pushd "%D%:\"

    "%D%:\W.bat"

    I'm trying to get the drive letter from a USB drive by searching for the name, it only works in the Command Prompt, but not when I run the batch file containing this script, it just opens diskpart and the batch file doesn't execute

    Salmon Trout

    • Guest
    Re: Problem with batch script designed to get drive letter
    « Reply #1 on: December 14, 2016, 01:07:02 PM »
    First of all,
    1. What exactly do you want the script to do?
    2. Where will the script be run from?


    yocool13

      Topic Starter


      Newbie

      • Experience: Familiar
      • OS: Other
      Re: Problem with batch script designed to get drive letter
      « Reply #2 on: December 15, 2016, 08:25:29 AM »
      1. I want the script to open another script on a USB drive that has changing drive letters, (as far as I'm aware) it gets the drive/volume letter by searching for the name of a drive and stores it in the variable "D", which is then later called to open the script located on the USB drive.

      2. The script will run from a CD partition attached to the USB drive, so that it can autorun.

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: Problem with batch script designed to get drive letter
      « Reply #3 on: December 15, 2016, 08:29:08 AM »
      Clear as mud...
      " Anyone who goes to a psychiatrist should have his head examined. "