Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

find usb drive with WMI cmd using drivetype 2

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
armasmike
Asked:
armasmike
  • 2
1 Solution
 
armasmikeAuthor Commented:
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
 
armasmikeAuthor Commented:
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now