Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:28:22+00:00 2026-05-30T01:28:22+00:00

Under Windows 7 I created a custom autostart entry for an usb device. This

  • 0

Under Windows 7 I created a custom autostart entry for an usb device. This entry starts a batch file on my harddisk, not on the usb-drive. My harddisk has always the same drive letter. How do I tell the batch file, which drive letter is being assigned to the usb device or how do I get this in the batch file itself?

I found that it is not %~d0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:28:25+00:00Added an answer on May 30, 2026 at 1:28 am

    I’m surprised %~d0 does not work, yet your batch file runs.

    If you can assign a unique volume label to your USB device, then you can try the following:

    for /f %%D in ('wmic volume get driveLetter^, label ^| find "yourLabel"') do set drive=%%D
    

    EDIT after reading comment – OK, %~d0 should not work because it will simply give the drive letter where your bat file resides – your hard drive.

    I still think WMIC is the utility you will need. If you are looking for a specific device, then I think my original answer might work. Another possibility is to substitute serialNumber for label in the wmic command. Plug your device in, identify which drive letter it is manualy, and then type wmic volume get driveLetter, serialNumber from the command line to identify what serial number you are looking for. Then you can use the following in your batch file

    for /f %%D in ('wmic volume get driveLetter^, serialNumber ^| find "yourSerialNumber"') do set drive=%%D
    

    Another possibility might be to put your batch file on the usb-device. If you can get auto-start to launch the batch file from your device, then you can use %~d0 to get the assigned drive letter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had created a zip file (together with directory) under Windows as follow (Code
I have created a folder under Windows\system32 with a config file in it. For
Under Windows Server 2003, Enterprise Edition, SP2 (/3GB switch not enabled) As I understand
Under Windows Vista and Win7 there is a problem with applications created by Delphi
I have a new rails application which I have created under Windows 7 by
I could not start an OpenCV application under Windows. Given the following simple OpenCV
I've created my application and tested it under windows, which writes/reads to/from a access
Iam having problems with dll import in c#. I created library under windows xp
Under Windows there are some handy functions like QueryPerformanceCounter from mmsystem.h to create a
Is there a way to create a 'kiosk mode' in wxpython under Windows (98

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.