Celtic88 Posted September 30, 2013 Posted September 30, 2013 I'm trying to convert this vbs script to autoit. I used two different converter and had no luck. Can anyone please help me? Set WshShell = CreateObject("WScript.Shell") key = "HKLMSOFTWAREMicrosoftWindows NTCurrentVersion" digitalId = WshShell.RegRead(key & "DigitalProductId") ProductName = "Product Name : " & WshShell.RegRead(key & "ProductName") & vbNewLine ProductId = "Product Id : " & WshShell.RegRead(key & "ProductId") & vbNewLine ProductKey = "Install Key : " & Converted(digitalId) ProductId = ProductName & ProductId & ProductKey boutons = vbYesNo + vbQuestion If vbYes = MsgBox(ProductId & vblf & vblf & "Save to a file ?", boutons, "Windows Infos") then Save ProductId End if Function Converted(id) Const OFFSET = 52 i = 28 Chars = "BCDFGHJKMPQRTVWXY2346789" Do Cur = 0 x = 14 Do Cur = Cur * 256 Cur = id(x + OFFSET) + Cur id(x + OFFSET) = (Cur 24) And 255 Cur = Cur Mod 24 x = x -1 Loop While x >= 0 i = i - 1 Converted = Mid(Chars, Cur + 1, 1) & Converted If (((29 - i) Mod 6) = 0) And (i <> -1) Then i = i -1 Converted = "-" & Converted End If Loop While i >= 0 End Function Function Save(data) Const ForWRITING = 2 Const asASCII = 0 Dim fso, f, fName, ts today = FormatDateTime(Date, vbLongDate) & vbnewline fName = "OS Key.txt" Set fso = CreateObject("Scripting.FileSystemObject") fso.CreateTextFile fName Set f = fso.GetFile(fName) Set f = f.OpenAsTextStream(ForWRITING, asASCII) f.Writeline today f.Writeline data f.Close End Function
water Posted September 30, 2013 Posted September 30, 2013 Doesn't look too complex. As the converters didn't help, did you try it yourself? What have you created so far? Which problems did you encounter? My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Celtic88 Posted September 30, 2013 Author Posted September 30, 2013 I am a newbie in programming , and I do not know anything in vbs
water Posted September 30, 2013 Posted September 30, 2013 (edited) Start with what you know about AutoIt and convert what looks similar in VB.ThisSet WshShell = CreateObject("WScript.Shell") key = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" digitalId = WshShell.RegRead(key & "DigitalProductId") ProductName = "Product Name : " & WshShell.RegRead(key & "ProductName") & vbNewLine ProductId = "Product Id : " & WshShell.RegRead(key & "ProductId") & vbNewLine ProductKey = "Install Key : " & Converted(digitalId) ProductId = ProductName & ProductId & ProductKey boutons = vbYesNo + vbQuestion If vbYes = MsgBox(ProductId & vblf & vblf & "Save to a file ?", boutons, "Windows Infos") then Save ProductId End ifcan easily be converted to$key = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" $digitalId = RegRead($key, "DigitalProductId") $ProductName = "Product Name : " & RegRead($key, "ProductName") & @LF $ProductId = "Product Id : " & RegRead($key, "ProductId") & @LF $ProductKey = "Install Key : " & Converted($digitalId) $ProductId = $ProductName & $ProductId & $ProductKey If MsgBox(4, "Windows Infos", $ProductId & @LF & @LF & "Save to a file ?") = 6 Then Save($ProductId) EndIfTry the rest and if you have problems, ask again. Edited September 30, 2013 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Celtic88 Posted September 30, 2013 Author Posted September 30, 2013 re , Cur = id(x + OFFSET) + Cur id(x + OFFSET) = (Cur 24) And 255 How to convert this code to autoit These attempt MsgBox(0, 'Сообщение', Converted(RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "DigitalProductId"))) Func Converted($id) Local $Return Const $OFFSET = 52 $i = 28 $Chars = "BCDFGHJKMPQRTVWXY2346789" Do $Cur = 0 $x = 14 Do $Cur = $Cur * 256 $Cur = ($x + $OFFSET) + $Cur ;; ? ($x + $OFFSET) = ($Cur / 24) And 255 $Cur = Mod($Cur , 24) $x = $x - 1 Until $x < 0 $i = $i - 1 $Return = StringMid($Chars, $Cur + 1, 1) & $Return If (Mod ((29 - $i) ,6) = 0) And ($i <> -1) Then $i = $i - 1 $Return &= "-" EndIf Until $i < 0 Return $Return EndFunc ;==>Converted
water Posted September 30, 2013 Posted September 30, 2013 On 9/30/2013 at 11:58 AM, Mrbenkali said: Cur = id(x + OFFSET) + Cur id(x + OFFSET) = (Cur 24) And 255 How to convert this code to autoit $Cur = id[$x + $Offset] + $Cur id[$x + $OFFSET] = BitAnd(Int($Cur/24)), 255) Looks like id is treated as an array. But I could be wrong. My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Celtic88 Posted November 2, 2013 Author Posted November 2, 2013 (edited) I finally found a solution : D - Add office cd key expandcollapse popupMsgBox(0, ' Retrieve Windows Product Info ', _GetWindowskey()) Func _GetWindowskey() Local $WindowscdKEy, $WindowsRegkey = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion' $WindowscdKEy = "Product Name : " & RegRead($WindowsRegkey, 'ProductName') & @CRLF $WindowscdKEy &= "Product Id : " & RegRead($WindowsRegkey, 'ProductId') & @CRLF $WindowscdKEy &= "Install Key : " & _Converted(RegRead($WindowsRegkey, 'DigitalProductId')) & @CRLF Local $OfficeCdkey, $ZOFkey, $Getnumkey Dim $OfficeVer[5] = ["10.0", "11.0", "12.0", "14.0", "15.0"] For $i = 0 To 4 $ZOFkey = 'HKLM\SOFTWARE\Microsoft\Office\' & $OfficeVer[$i] & '\Registration\' $Getnumkey = _Getnumkey($ZOFkey) If $Getnumkey[0] <> "" Then For $Ii = 1 To $Getnumkey[0] $OfficeCdkey &= "Product Name : " & RegRead($ZOFkey & $Getnumkey[$Ii], 'ProductName') & @CRLF $OfficeCdkey &= "Product Id : " & RegRead($ZOFkey & $Getnumkey[$Ii], 'ProductId') & @CRLF $OfficeCdkey &= "Install Key : " & _Converted(RegRead($ZOFkey & $Getnumkey[$Ii], 'DigitalProductId')) & @CRLF & @CRLF Next EndIf Next Return '-Windows key : ' & @CRLF & @CRLF & $WindowscdKEy & @CRLF & '-Office Key : ' & @CRLF & @CRLF & $OfficeCdkey EndFunc ;==>_GetWindowskey Func _Converted($id) $id = _KEyArry($id) Local $Converted, $Cur, $x Local Const $OFFSET = 52 Local $i = 28 Local $Chars = "BCDFGHJKMPQRTVWXY2346789" Do $Cur = 0 $x = 14 Do $Cur = $Cur * 256 $Cur = $id[$x + $OFFSET] + $Cur $id[$x + $OFFSET] = BitAND(Int(($Cur / 24)), 255) $Cur = Mod($Cur, 24) $x = $x - 1 Until $x < 0 $i = $i - 1 $Converted = StringMid($Chars, $Cur + 1, 1) & $Converted If Mod((29 - $i), 6) = 0 And $i <> -1 Then $i = $i - 1 $Converted = "-" & $Converted EndIf Until $i < 0 Return $Converted EndFunc ;==>_Converted Func _KEyArry($BIn) Local $Count Local $Slen = StringLen($BIn) Dim $keyarray[BinaryLen($BIn)] For $i = 3 To $Slen Step 2 $keyarray[$Count] = Dec(StringMid($BIn, $i, 2)) $Count += 1 Next Return $keyarray EndFunc ;==>_KEyArry Func _Getnumkey($Skey) Local $i, $Vkey Dim $NumkeyArry[1] While True $i += 1 $Vkey = RegEnumKey($Skey, $i) If @error Then ExitLoop ReDim $NumkeyArry[$i + 1] $NumkeyArry[0] = $i $NumkeyArry[$i] = $Vkey WEnd Return $NumkeyArry EndFunc ;==>_Getnumkey Edited November 3, 2013 by Mrbenkali
ricky Posted January 22, 2016 Posted January 22, 2016 (edited) Hello, AutoIt v 3.3.14.1 sorry to open again this topic, but the script above doesn't work. Quote "C:\Temp\temp-12.au3" (39) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Cur = $id[$x + $OFFSET] + $Cur $Cur = ^ ERROR Expand Could you please help me? I don't understand the goal of the function "Func _KEyArry"! In the VBS script is more easy! For information, the topic with a vbs script working : http://www.eightforums.com/installation-setup/13555-how-do-i-find-my-product-key-post146433.html#post146433 Thanks for your help Edited January 22, 2016 by ricky Add version
water Posted January 22, 2016 Posted January 22, 2016 (edited) This works with Windows 7 64 bit and Office 10 32 bit: expandcollapse popupMsgBox(0, ' Retrieve Windows Product Info ', _GetWindowskey()) Func _GetWindowskey() Local $WindowscdKEy, $WindowsRegkey = 'HKLM64\SOFTWARE\Microsoft\Windows NT\CurrentVersion' $WindowscdKEy = "Product Name : " & RegRead($WindowsRegkey, 'ProductName') & @CRLF $WindowscdKEy &= "Product Id : " & RegRead($WindowsRegkey, 'ProductId') & @CRLF $WindowscdKEy &= "Install Key : " & _Converted(RegRead($WindowsRegkey, 'DigitalProductId')) & @CRLF Local $OfficeCdkey, $ZOFkey, $Getnumkey Dim $OfficeVer[5] = ["10.0", "11.0", "12.0", "14.0", "15.0"] For $i = 0 To 4 $ZOFkey = 'HKLM\SOFTWARE\Microsoft\Office\' & $OfficeVer[$i] & '\Registration\' $Getnumkey = _Getnumkey($ZOFkey) If $Getnumkey[0] <> "" Then For $Ii = 1 To $Getnumkey[0] $sProductName = RegRead($ZOFkey & $Getnumkey[$Ii], 'ProductName') If @error Then $sProductName = RegRead($ZOFkey & $Getnumkey[$Ii], 'ProductNameNonQualified') $sProductId = RegRead($ZOFkey & $Getnumkey[$Ii], 'ProductId') $sProductDId = RegRead($ZOFkey & $Getnumkey[$Ii], 'DigitalProductId') If @error = 0 Then $OfficeCdkey &= "Product Name : " & $sProductName & @CRLF $OfficeCdkey &= "Product Id : " & $sProductId & @CRLF $OfficeCdkey &= "Install Key : " & _Converted($sProductDId) & @CRLF & @CRLF EndIf Next EndIf Next Return '-Windows key : ' & @CRLF & @CRLF & $WindowscdKEy & @CRLF & '-Office Key : ' & @CRLF & @CRLF & $OfficeCdkey EndFunc ;==>_GetWindowskey Func _Converted($id) $id = _KEyArry($id) Local $Converted, $Cur, $x Local Const $OFFSET = 52 Local $i = 28 Local $Chars = "BCDFGHJKMPQRTVWXY2346789" Do $Cur = 0 $x = 14 Do $Cur = $Cur * 256 $Cur = $id[$x + $OFFSET] + $Cur $id[$x + $OFFSET] = BitAND(Int(($Cur / 24)), 255) $Cur = Mod($Cur, 24) $x = $x - 1 Until $x < 0 $i = $i - 1 $Converted = StringMid($Chars, $Cur + 1, 1) & $Converted If Mod((29 - $i), 6) = 0 And $i <> -1 Then $i = $i - 1 $Converted = "-" & $Converted EndIf Until $i < 0 Return $Converted EndFunc ;==>_Converted Func _KEyArry($BIn) Local $Count Local $Slen = StringLen($BIn) Dim $keyarray[BinaryLen($BIn)] For $i = 3 To $Slen Step 2 $keyarray[$Count] = Dec(StringMid($BIn, $i, 2)) $Count += 1 Next Return $keyarray EndFunc ;==>_KEyArry Func _Getnumkey($Skey) Local $i, $Vkey Dim $NumkeyArry[1] While True $i += 1 $Vkey = RegEnumKey($Skey, $i) If @error Then ExitLoop ReDim $NumkeyArry[$i + 1] $NumkeyArry[0] = $i $NumkeyArry[$i] = $Vkey WEnd Return $NumkeyArry EndFunc ;==>_Getnumkey Edited January 22, 2016 by water My UDFs and Tutorials: Reveal hidden contents UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
ricky Posted January 25, 2016 Posted January 25, 2016 (edited) Hello, thanks for your help, but it doesn't work in Windows server 2012, but the vbs under the link above works, but I don't understand the difference. Who can help me? Edited January 25, 2016 by ricky
Moderators JLogan3o13 Posted January 25, 2016 Moderators Posted January 25, 2016 @rickyyou need to provide a little more than "it doesn't work". What is happening? What are you seeing? Are you getting an error? etc. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
ricky Posted January 25, 2016 Posted January 25, 2016 (edited) Right, sorry, no error, it don't give the good license number. Edited January 25, 2016 by ricky
Moderators JLogan3o13 Posted January 29, 2016 Moderators Posted January 29, 2016 Again, can you expand on this? Does it return anything at all? Just a blank? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
ricky Posted January 29, 2016 Posted January 29, 2016 It returns a license key, but not the good one.
ricky Posted February 17, 2016 Posted February 17, 2016 Nobody can help me to fix this problem? Or translate the VBS script to autoit?
mLipok Posted February 17, 2016 Posted February 17, 2016 On 1/29/2016 at 3:48 PM, ricky said: It returns a license key, but not the good one. Expand So try to find your licencse key via email or any other documents which you get from the developer. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Reveal hidden contents Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
ricky Posted February 17, 2016 Posted February 17, 2016 (edited) Thanks for your answer, but it's not the problem. I have the sticker with my license key (Windows server 2012). But I as already integrated a script in a program home made, but it returns not the good license number. But in my answer above #8, the script shows the good license. I just want to convert this script to autoit... Edited February 17, 2016 by ricky
jguinch Posted February 17, 2016 Posted February 17, 2016 @ricky, look at this one : Reveal hidden contents Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now