→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎01-09-2015 11:35 PM - last edited on ‎04-01-2024 04:50 PM by Mercedes_O
Hello all,
I thought I share a great custom action that uses a Vbscript that I created to aid in our OEM activation process if one of my tech's forget to activate Windows after using MDT to image a machine as we use OEM versions of Windows Pro. We have a mixed Win 7/8.1 environment so this was the need for using PsExec since a Win 8 slmgr.vbs script will not activate a Win 7 machine and vise versa. We utilize "Comments" page to record the OEM product key as part of our SOP when we acquire new computers to make a record of the OEM key and to easily copy and paste if we need to activate after an new image is applied. For OEM computers that shipped with Win 8 please visit this site to find out how to record the OEM key since I know people are going to ask.
This will even work for MAK keys as we use it activate our servers with the correct MAK after deployments.
In short, this script does the following: uninstalls current key, installs new key that you typed in, activates online, and then displays the licensing status for that computer.
You will need the following in your Lansweeper server's action path:
PsExec
activateWindows.vbs (create from the code below)
Here is the code:
'Pass computer name from Lansweeper to script
strComputer = WScript.Arguments(0)
'Instantiate variables
Set objScript = CreateObject("WScript.Shell")
Set objRegExp = CreateObject("Vbscript.RegExp")
' Define Regular expression
objRegExp.Global = True
objRegExp.Pattern = "^[a-z0-9]{5}(-[a-z0-9]{5}){4}$"
objRegExp.IgnoreCase = True
Do
' Input new product key
sKeyLoop = 0
Dim sProductKey
sProductKey = InputBox("Please enter the Product Key for this computer with the -'s: ", "New Product Key", "")
If trim(sProductKey) = "" Then 'If blank
Wscript.Quit
End If
sProductKey = Replace(sProductKey, " ", "")
sProductKey = trim(UCase(sProductKey))
'Tests to see if valid product key format
If objRegExp.Test(sProductKey) Then
'Continues script
Call ActivateWindows()
Else
Wscript.Echo ("Invalid entry.")
sKeyLoop = 0
End If
Loop While sKeyLoop = 0
'Function for activating windows using PsExec and slmgr.vbs
Function ActivateWindows()
sCmdUninstall = "\\<servername>\lansweeper$\PSTools\PsExec.exe \\" & strComputer & " cscript.exe ""C:\windows\system32\slmgr.vbs"" /upk"
sCmdInstall = "\\<servername>\lansweeper$\PSTools\PsExec.exe \\" & strComputer & " cscript.exe ""C:\windows\system32\slmgr.vbs"" /ipk " & sProductKey
sCmdActivate = "\\<servername>\lansweeper$\PSTools\PsExec.exe \\" & strComputer & " cscript.exe ""C:\windows\system32\slmgr.vbs"" /ato"
sCmdViewLicense = "\\<servername>\lansweeper$\PsExec.exe \\" & strComputer & " cscript.exe ""C:\windows\system32\slmgr.vbs"" /dli"
'Run cmds
objScript.Run sCmdUninstall, 0, True
objScript.Run sCmdInstall, 0, True
objScript.Run sCmdActivate, 0, True
objScript.Run ("%comspec% /K " & sCmdViewLicense)
Wscript.Quit
End Function
Here is the action code for the Asset Pages:
Code:
{actionpath}activateWindows.vbs "{computer}"
I hope you enjoy !
Keys_IT
‎11-02-2017 07:34 PM
‎05-03-2016 06:55 PM
‎04-30-2016 02:57 AM
‎04-29-2016 07:04 PM
‎04-29-2016 06:34 PM
‎04-29-2016 06:01 PM
‎02-25-2016 03:19 PM
‎02-16-2016 11:03 PM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now