I'm just a hack who shoehorns VBScript code I find on the web together so I fully admit I don't know what I'm doing.
I'm trying to query a user for their BIOS password, create a command line including that variable and feed the command line to the program HPQPswd64.exe to generate an encrypted password file called PWORD.BIN. Because this file will then be fed into a command line of another program that requires elevation, I need to self-elevate the script.
My script works fine until I add the self-elevation code and I'm not sure what's happening due to my ignorance of how the elevation script works. The script and the executable are in the same folder and the PWORD.BIN file it creates is placed in the same folder, as well.
The code I have that works is:
then, if I add the self-elevation code, it elevates, asks for input but the executable doesn't run (I think) and no PWORD.BIN is created:
Any insight you can give me on why this is happening and how to fix it would be VERY appreciated.
I'm trying to query a user for their BIOS password, create a command line including that variable and feed the command line to the program HPQPswd64.exe to generate an encrypted password file called PWORD.BIN. Because this file will then be fed into a command line of another program that requires elevation, I need to self-elevate the script.
My script works fine until I add the self-elevation code and I'm not sure what's happening due to my ignorance of how the elevation script works. The script and the executable are in the same folder and the PWORD.BIN file it creates is placed in the same folder, as well.
The code I have that works is:
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
DIM PwdProg, PWORD
PWORD=InputBox(" --===== WARNING =====-- Disabling SecureBoot may trigger BitLocker Recovery on next reboot. Make sure you have the BitLocker Recovery key on hand before disabling SecureBoot!!!", "SecureBoot Disabler")
PwdProg = """"&"HPQPswd64.exe /S /P"&""""&PWORD&""""&" /F"&""""&"PWORD.BIN"&""""&""""
WshShell.Run "cmd /c " & PwdProg, 0, True
then, if I add the self-elevation code, it elevates, asks for input but the executable doesn't run (I think) and no PWORD.BIN is created:
Code:
'--------------
'Start of UAC workaround code
If WScript.Arguments.length =0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & _
WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else
'--------------
'Start of code
'This code is ran as an elevated user, ie. Administrator
strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
DIM PwdProg, PWORD
PWORD=InputBox(" --===== WARNING =====-- Disabling SecureBoot may trigger BitLocker Recovery on next reboot. Make sure you have the BitLocker Recovery key on hand before disabling SecureBoot!!!", "SecureBoot Disabler")
PwdProg = """"&"HPQPswd64.exe /S /P"&""""&PWORD&""""&" /F"&""""&"PWORD.BIN"&""""&""""
WshShell.Run "cmd /c " & PwdProg, 0, True
'--------------
'End of code
'--------------
'End of UAC workaround code
End If
Any insight you can give me on why this is happening and how to fix it would be VERY appreciated.