Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

WinPE / WDS / scripting How to know which volume my USB disk is assigned (automatically)

Posted on 2011-10-14
6
Medium Priority
?
379 Views
Last Modified: 2012-05-12
I have created a bootable USB drive with an install image on it. To deploy the image I script imagex /apply {file}
The problem I am having is that depending on how many volumes are already on the computer about to be imaged, my USB drive could be assigned any of several different letters (D: E: F:)
Since my install.wim is on the root of the USB drive and that changes I  need a way to find out what letter it is and contain that as a variable in a batch script.
0
Comment
Question by:Lafflin
  • 4
6 Comments
 
LVL 11

Accepted Solution

by:
X_layer earned 2000 total points
ID: 36971128
Look here for solution.
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36971483
If the batch file you are running is on the USB drive then the following will return the drive's letter:

   set drive=%~d0
   :
   echo %drive%

0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36971527
You can run this one off any drive. It identifies drive letters (excluding A: and B:)

for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
   if exist %%a:\. (
      echo %%a
   )
)
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 11

Expert Comment

by:paultomasi
ID: 36971539
Try this....

for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
   if exist "%%a:\program.ext"
      "%%a:\program.ext"
   )
)

Where 'program.ext' is the program on your USB drive
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36971555
Or perhaps you just need to access data on the usb drive like this...

for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
   if exist "%%a:\datafile"
      program "%%a:\datafile"
      exit /b
   )
)

0
 
LVL 1

Author Comment

by:Lafflin
ID: 36979422
That was exactly the answer I was looking for, thanks much.
While paulto was correct as well I have to give the point to X as his answer was correct first.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question