cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
eig
Punch Card
Posts: 13
Location: Geneva
10,168 Views
Message 1 of 23

Do you have a vb script to set a new BIOS Supervisor Password?

Hi,

 

I found a script who update the BIOS password:

*****************************************************

 

'
' Update Administrator Password
'
On Error Resume Next
Dim colItems
If WScript.Arguments.Count <> 3 Then
    WScript.Echo "SetAdminPassword.vbs [oldpassword] [newpassword] [encoding]"
    WScript.Quit
End If
strRequest = "pap,"+WScript.Arguments(0)+"," + WScript.Arguments(1) + "," +WScript.Arguments(2)+";"
strComputer = "LOCALHOST"     ' Change as needed.
Set objWMIService = GetObject("WinMgmts:" _
    &"{ImpersonationLevel=Impersonate}!\\" & strComputer & "\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SetBiosPassword")
strReturn = "error"
For Each objItem in colItems
    ObjItem.SetBiosPassword strRequest, strReturn
Next
WScript.Echo strRequest
WScript.Echo " SetBiosPassword: "+ strReturn

'' Update Administrator Password'On Error Resume NextDim colItemsIf WScript.Arguments.Count <> 3 Then    WScript.Echo "SetAdminPassword.vbs [oldpassword] [newpassword] [encoding]"    WScript.QuitEnd If
strRequest = "pap,"+WScript.Arguments(0)+"," + WScript.Arguments(1) + "," +WScript.Arguments(2)+";"strComputer = "LOCALHOST"     ' Change as needed.Set objWMIService = GetObject("WinMgmts:" _    &"{ImpersonationLevel=Impersonate}!\\" & strComputer & "\root\wmi")Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SetBiosPassword")
strReturn = "error"For Each objItem in colItems    ObjItem.SetBiosPassword strRequest, strReturnNext
WScript.Echo strRequestWScript.Echo " SetBiosPassword: "+ strReturn

 

 

*****************************************************

 

But do you know how to modify this script in order to set a new password when the old one is blank?

 

Thanks in advance,

 

Josh

Lenovo Staff
Lenovo Staff
Posts: 4,128
Location: NC
10,136 Views
Message 2 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

It is not possible to set a password with the WMI interface when a password does not already exist.  This is for security reasons.  Otherwise it would be possible to have malware which runs in Windows, sets passwords that you don't know, and locks you out of your system.

 

It can be done in DOS.  Some customers boot a DOS disk as part of their unboxing procedure to set a known password.  Then they can change it by WMI later (if they want to).  Some large customers order their systems from the Lenovo factory with a known password installed, talk to your account manager if you fall into that category.

pollewops
Punch Card
Posts: 16
Location: Netherlands
10,012 Views
Message 3 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

I tried using the script but it seems that the error handling is not working properly.

I always get a SuccessFull in return although I put in a wrong initial set password.

 

Any ideas ?

Lenovo Staff
Lenovo Staff
Posts: 4,128
Location: NC
10,011 Views
Message 4 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?


pollewops wrote:

I tried using the script but it seems that the error handling is not working properly.

I always get a SuccessFull in return although I put in a wrong initial set password.

 

Any ideas ?



Need more info.  What script are you using?  What is the exact input and output?

pollewops
Punch Card
Posts: 16
Location: Netherlands
10,008 Views
Message 5 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

I use the following script on my X201 which has an initial HD1 password set to "welcome"

 

On Error Resume Next

Dim colItems
Dim objNetwork, objShell
Dim strComputer, strRequest
Dim arrayfr, arrayus, arraygr
Dim strLocale, strlocaleCode
Dim oldpassword, newpassword, encoding
Dim objWMIService, colItems, strReturn

Set objNetwork = CreateObject("WScript.Network")
Set objShell = WScript.CreateObject("WScript.Shell")

strComputer = "localhost"

arrayfr = "0x0000080c,0x0000040c"
arrayus = "0x00001009,0x00000404,0x00000406,0x00000413,0x00000410,0x00000411,0x00000412,0x00000414,0x00000415,0x00000816,0x0000040a,0x00000807,0x0000041f,0x00000452,0x00000409"
arraygr = "0x00000405,0x00000407,0x0000041b,0x00000424"

strLocale = objShell.RegRead("HKCU\Control Panel\International\Locale")

strlocaleCode = "us"
if instr(arrayfr,strLocale) > 0 then strlocaleCode = "fr"
if instr(arraygr,strLocale) > 0 then strlocaleCode = "gr"

'wscript.echo strlocale
'wscript.echo strlocaleCode

oldpassword = "welcome"
newpassword = "test1234"
encoding    = "ascii," & strlocaleCode

strRequest = "uhdp1," + oldpassword + "," + newpassword + "," + encoding + ";"

'wscript.echo strRequest

wscript.quit

Set objWMIService = GetObject("WinMgmts:{ImpersonationLevel=Impersonate}!\\" & strComputer & "\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SetBiosPassword")

strReturn = "error"

For Each objItem in colItems
  ObjItem.SetBiosPassword strRequest, strReturn
Next

WScript.Echo " SetBiosPassword: " + strReturn

 When I type in the script instead of "welcome" e.g. "testttt" as initial password (oldpassword) the outcome of the script is Success and that is strange. When set oldpassword to "welcome" then the script seems to work....

But I want to do some errorhandling in it...but I cant get it worked....

 

I want to provide my end users this piece of script in a GUII based HTA application. but then the error handling should work as well. I need to inform the user if they types the wrong "oldpassword"....

Lenovo Staff
Lenovo Staff
Posts: 4,128
Location: NC
10,002 Views
Message 6 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

OK, I see what you are saying.  I will investigate this and get back to you.

pollewops
Punch Card
Posts: 16
Location: Netherlands
9,998 Views
Message 7 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

THANKS !!!

Lenovo Employee wstolte
Lenovo Employee
Posts: 1
Location: USA
9,814 Views
Message 8 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

Was there ever a resolution to this?

Lenovo Staff
Lenovo Staff
Posts: 4,128
Location: NC
9,811 Views
Message 9 of 23

Re: Do you have a vb script to set a new BIOS Supervisor Password?

There is no solution to this problem about entering the wrong HDD password in the script.  It is simply not possible to verify the HDD password during the processing of the script.  The HDD password is only verified during the next BIOS POST.

 

So even though the script returns SUCCESS, it does not mean that the correct HDD password was provided as input.  It just means that the command was written to BIOS so that it will be executed on the next reboot.  If the wrong HDD password was provided as input then there will be an error during the next BIOS POST.

Paul3241
Blue Screen Again
Posts: 4
Location: Germany
9,516 Views
Message 10 of 23

Betreff: Do you have a vb script to set a new BIOS Supervisor Password?

Hello,

 

I have tried the following script which one can find all over the internet especially here in the forum. I tried to let it run on a lenovo thinkcenter PC because in our company we have a lot of them. The specific PC typ I cannot mention, but I used the right script because there are different ones for PC and notebooks. Has somebody an idea why the script always delivers an "error" output? Thanx a lot in advance!

Paul3241

 

On Error Resume Next

Dim colItems

If WScript.Arguments.Count <> 3 Then

WScript.Echo "SetSupervisorPassword.vbs [old Password] [new Password]

[encoding]" WScript.Quit

End If

strRequest = "pap," + WScript.Arguments(0) + "," + WScript.Arguments(1) + "," +

WScript.Arguments(2) + ";"

strComputer = "LOCALHOST" ’ Change as needed.

Set objWMIService = GetObject("WinMgmts:" _

&"{ImpersonationLevel=Impersonate}!\\" & strComputer & "\root\wmi")

Set colItems = objWMIService.ExecQuery("Select * from Lenovo_SetBiosPassword")

strReturn = "error"

For Each objItem in colItems

ObjItem.SetBiosPassword strRequest, strReturn

Next

WScript.Echo " SetBiosPassword: "+ strReturn

 

P.S. I took attention to have set an "old" Bios password

Top Kudoed Authors