[Help]Simple script command to relock disk using bitlocker

Discuss and share scripts and script files...
Post Reply
hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

[Help]Simple script command to relock disk using bitlocker

Post 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

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Help]Simple script command to relock disk using bitlocker

Post 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';
One of my scripts helped you out? Please donate via Paypal

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

Re: [Help]Simple script command to relock disk using bitlocker

Post 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.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Help]Simple script command to relock disk using bitlocker

Post 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...
One of my scripts helped you out? Please donate via Paypal

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

Re: [Help]Simple script command to relock disk using bitlocker

Post by hyzhangzhy »

Oh, it seems after I start xyplorer with admin rights,

The command works. :lol:

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: [Help]Simple script command to relock disk using bitlocker

Post 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...
One of my scripts helped you out? Please donate via Paypal

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

Re: [Help]Simple script command to relock disk using bitlocker

Post 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

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

Re: [Help]Simple script command to relock disk using bitlocker

Post 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

hyzhangzhy
Posts: 27
Joined: 05 Jan 2017 02:52

Re: [Help]Simple script command to relock disk using bitlocker

Post 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. :D

Post Reply