Solved

find usb drive with WMI cmd using drivetype 2

Posted on 2014-10-30
2
358 Views
Last Modified: 2014-10-31
ok i need a hand on this i am trying to get a cmd that will find the usb thumb drive in any computer i plug it in to.

The usb drive in a winpe with 2 partitions.

partitions 1  is the winpe
partitions 2 is the images

It's also bitlocked

i have this script i found the file name is unlock

@echo off & cls

set Volume=%1:

echo.

manage-bde.exe -unlock -password %Volume%

echo. & pause & echo.

:: End of script

Open in new window


to run it i just unlock d

the D drive would be the bitlocked usb drive. It would ask for the password i enter it in and it unlocks it for me.

That's great after it unlock i want it to launch a hta file on the unlocked usb drive.


What i need help with is HOW do i find the usb drive letter and have it run the command unlock "drive letter it finds"

I always what it to prompt for the password i type it in and them it opens the hta file on the usb drive
0
Comment
Question by:armasmike
  • 2
2 Comments
 

Author Comment

by:armasmike
ID: 40416079
this is what i have so far

strComputer = "."
Set oShell = WScript.CreateObject ("WScript.shell") 
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDisk")

For Each objDisk in colDisks
 
 Select Case objDisk.DriveType

 Case 2

Wscript.Echo "DeviceID: "& objDisk.DeviceID & " Removable drive."
 
 
  oShell.run "manage-bde.exe -unlock -password " & "objDisk.DeviceID"
 
 End Select
Next

Open in new window


is not quite working what am i missing ?
0
 

Accepted Solution

by:
armasmike earned 0 total points
ID: 40416084
well looks like i got it working

i used this as the run command

oShell.run "cmd /K manage-bde.exe -unlock -password " & objDisk.DeviceID

Open in new window


and it works i enter the password and drive is unlocked.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now