@@ -93,26 +93,6 @@ public static string[] CommandLineToArgs(string commandLine)
93
93
}
94
94
}
95
95
96
- public static void UnlockBitlockerDrive ( string drive , string password )
97
- {
98
- try
99
- {
100
- Process process = new Process ( ) ;
101
- process . StartInfo . UseShellExecute = true ;
102
- process . StartInfo . Verb = "runas" ;
103
- process . StartInfo . FileName = "powershell.exe" ;
104
- process . StartInfo . CreateNoWindow = true ;
105
- process . StartInfo . WindowStyle = ProcessWindowStyle . Hidden ;
106
- process . StartInfo . Arguments = $ "-command \" $SecureString = ConvertTo-SecureString '{ password } ' -AsPlainText -Force; Unlock-BitLocker -MountPoint '{ drive } ' -Password $SecureString\" ";
107
- process . Start ( ) ;
108
- process . WaitForExit ( 30 * 1000 ) ;
109
- }
110
- catch ( Win32Exception )
111
- {
112
- // If user cancels UAC
113
- }
114
- }
115
-
116
96
public static ( string icon , bool isCustom ) GetFileOverlayIcon ( string path )
117
97
{
118
98
var shfi = new Shell32 . SHFILEINFO ( ) ;
@@ -149,13 +129,19 @@ private static void RunPowershellCommand(string command, bool runAsAdmin)
149
129
process . StartInfo . WindowStyle = ProcessWindowStyle . Hidden ;
150
130
process . StartInfo . Arguments = command ;
151
131
process . Start ( ) ;
132
+ process . WaitForExit ( 30 * 1000 ) ;
152
133
}
153
134
catch ( Win32Exception )
154
135
{
155
136
// If user cancels UAC
156
137
}
157
138
}
158
139
140
+ public static void UnlockBitlockerDrive ( string drive , string password )
141
+ {
142
+ RunPowershellCommand ( $ "-command \" $SecureString = ConvertTo-SecureString '{ password } ' -AsPlainText -Force; Unlock-BitLocker -MountPoint '{ drive } ' -Password $SecureString\" ", true ) ;
143
+ }
144
+
159
145
public static void OpenFormatDriveDialog ( string drive )
160
146
{
161
147
// format requires elevation
0 commit comments