"vbs unlock bitlocker" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "vbs unlock bitlocker" answered properly. Developers are finding an appropriate answer about vbs unlock bitlocker related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like vbs unlock bitlocker. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on vbs unlock bitlocker. 

vbs unlock bitlocker

By 0nline0nline on Aug 09, 2020
Set oShell = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' :CONFIGURATION:

' Unlock a drive with the letter "E:", the name "test" and its recovery key
Call PossiblyUnlock (_
	"E",_
	"test",_
	"YOUR-BITLOCKER-RECOVERY-KEY-HERE"_
)


' :FUNCTIONS:

' Runs the current process with administrator rights if it ain't already
Function RunAsAdmin ()
	If Not WScript.Arguments.Named.Exists("elevate") Then
		CreateObject("Shell.Application").ShellExecute WScript.FullName _
			, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
		WScript.Quit
	End If
End Function

' Checks if the drive with the given letter and name is available
' Params:
' - letter: letter of the drive
' - name: name of the drive
' Returns:
' - 0: Drive not found
' - 1: Error (-> Drive possibly locked)
' - 2: Drive available
Function CheckForDrive (letter, name)
	CheckForDrive = 0
	On Error Resume Next
	If fso.DriveExists(letter) Then
		Set drive = fso.GetDrive(letter)
		If drive.VolumeName = name Then
			CheckForDrive = 2
		End If
	End If
	If Err.Number <> 0 Then
		CheckForDrive = 1
	End If
	On Error Goto 0
End Function

' Unlocks a BitLocker locked drive if neccessary
' Params:
' - letter: letter of the drive
' - name: name of the drive
' - password: BitLocker recovery key to unlock the locked drive
' Returns:
' - Boolean: Was the drive successfully unlocked
Function PossiblyUnlock (letter, name, password)
	PossiblyUnlock = False
	If CheckForDrive(letter, name) = 1 Then
		RunAsAdmin
		cmd = "manage-bde -unlock D: -RecoveryPassword " & password
		oShell.Run cmd, 0, True
		If CheckForDrive(letter, name) = 2 Then
			PossiblyUnlock = True
		End If
	End If
End Function

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on vbs unlock bitlocker can get a collection of related answers to their query. Programmers need to enter their query on vbs unlock bitlocker related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about vbs unlock bitlocker for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of vbs unlock bitlocker while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "vbs unlock bitlocker". Visit this developer's friendly online web community, CodeProZone, and get your queries like vbs unlock bitlocker resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "vbs unlock bitlocker"

View All Whatever queries

Whatever queries related to "vbs unlock bitlocker"

Browse Other Code Languages

CodeProZone