Page 1 of 1
[Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 06:27
by hyzhangzhy
I am beginner in XYplorer scripting.
Since the malware was rampant recently...
I am trying to write a script to relock my disk using bitlocker and link it to a button on the xyplorer toolbar so that I can easily relock the disk in one click.
Here is the command to relock the disk "E:\" that I found via google:
Code: Select all
manage-bde.exe -lock e: -forcedismount
After reading the help topic for a while I try this script.
Code: Select all
run '"C:\Windows\System32\manage-bde.exe" "-lock e: -forcedismount"', , ,1;
However, it does not work...
Am I missing something?
Thanks
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 07:48
by highend
- Does that command need admin rights?
- 32 / 64 bit OS?
Put a step; in front of it to see how it is resolved
Code: Select all
step; run '"C:\Windows\System32\manage-bde.exe" -lock e: -forcedismount';
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 08:08
by hyzhangzhy
Hi, highend
Thanks
Yes, it seems that the command need admin rights, may I ask how can I ask for it in script or is there some other ways to get it?
I am using win10 x64.
And after adding a step the commandline window shows with a message access deny need admin rights.
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 08:24
by highend
It seems hidden start isn't freeware anymore... (
http://www.ntwind.com/software/hstart.html)
I do such things like this:
Code: Select all
$comspec = ("%osbitness%" == 64) ? "%windir%\System32\cmd.exe" : "%windir%\SysWOW64\cmd.exe";
$cscript = ("%osbitness%" == 64) ? "%windir%\System32\cscript.exe" : "%windir%\SysWOW64\cscript.exe";
$vbsFile = "%TEMP%\~OpenElevatedCMD.vbs";
$vbsContent = <<<>>>
Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "$comspec", "/k pushd ""<curpath>""", "", "runas", 1
>>>;
writefile($vbsFile, trim($vbsContent));
run """$cscript"" ""$vbsFile"" //nologo", , 0, 0;
Things to be aware of:
- Ofc you need to change the UAC.ShellExecute line
- You can try to call $comspec and $cscript with System32 paths (and not SysWOW64)
otherwise you need the sysnative redirection
There are other tools than hidden start but they were never that reliable...
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 08:26
by hyzhangzhy
Oh, it seems after I start xyplorer with admin rights,
The command works.

Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 08:29
by highend
Sure but do you REALLY want to run it all the time with admin permissions?
E.g. drag and drop between applications and XY can cease to function (e.g. drag an URL
from a browser to XY) if the source application isn't running with admin permissions as well...
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 08:58
by hyzhangzhy
Oh, I see.
But, I currently do not know how to write a vbscript...
Could you help me to change the UAC.ShellExecute line to make it exec that command?
Thanks
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 09:17
by hyzhangzhy
Oh, I figure it out finally...
Code: Select all
$cscript = ("%osbitness%" == 64) ? "%windir%\System32\cscript.exe" : "%windir%\SysWOW64\cscript.exe";
$vbsFile = "%TEMP%\~OpenElevatedCMD.vbs";
$vbsContent = <<<>>>
Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "C:\Windows\System32\manage-bde.exe", "-lock e: -forcedismount", "", "runas", 1
>>>;
writefile($vbsFile, trim($vbsContent));
run """$cscript"" ""$vbsFile"" //nologo", , 0, 0;
Thanks for your help highend
Re: [Help]Simple script command to relock disk using bitlocker
Posted: 17 May 2017 09:21
by hyzhangzhy
Code: Select all
$cscript = ("%osbitness%" == 64) ? "%windir%\System32\cscript.exe" : "%windir%\SysWOW64\cscript.exe";
$vbsFile = "%TEMP%\~Unlock.vbs";
$vbsContent = <<<>>>
Set UAC = CreateObject("Shell.Application")
UAC.ShellExecute "C:\Windows\System32\manage-bde.exe", "-lock e: -forcedismount", "", "runas", 0
>>>;
writefile($vbsFile, trim($vbsContent));
run """$cscript"" ""$vbsFile"" //nologo", , 0, 0;
Maybe this one better, no black windows.
