Sign in to follow this  
Followers 0
BoogY

script translation

8 posts in this topic

Hi there every one...

I come once more for your help..

i need to translate this vbScript in to autoit:

on error resume next

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\" & strcomputer & ".txt", True)

strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"

Set objReg = GetObject("winmgmts://" & strComputer & _
 "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys

For Each strSubkey In arrSubkeys
  intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
   strEntry1a, strValue1)
  If intRet1 <> 0 Then
    objReg.GetStringValue HKLM, strKey & strSubkey, _
     strEntry1b, strValue1
  End If
  If strValue1 <> "" Then
objTextFile.WriteLine strValue1 & "¿ " & strcomputer & "¿"
  End If
Next

strKey2 = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry2a = "DisplayName"
strEntry2b = "QuietDisplayName"

Set objReg = GetObject("winmgmts://" & strComputer & _
 "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey2, arrSubkeys

For Each strSubkey In arrSubkeys
  intRet2 = objReg.GetStringValue(HKLM, strKey2 & strSubkey, _
   strEntry2a, strValue2)
  If intRet2 <> 0 Then
    objReg.GetStringValue HKLM, strKey & strSubkey, _
     strEntry2b, strValue2
  End If
  If strValue2 <> "" Then
objTextFile.WriteLine strValue2 & "¿ " & strcomputer & "¿"
  End If
Next

objTextFile.Close

Thanks a lot for your help

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

No I'm trying my self.

Prof :

i made it like this : is this correct ?

Func listInstalledApps()

    Const $HKLM = "&H80000002" ;HKEY_LOCAL_MACHINE
    $objNetwork = ObjCreate("Wscript.Network")
    $strComputer = $objNetwork.ComputerName

    $objFSO = ObjCreate("Scripting.FileSystemObject")
    $objTextFile = $objFSO.CreateTextFile("c:\" & $strcomputer & ".txt", True)

    $strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
    $strEntry1a = "DisplayName"
    $strEntry1b = "QuietDisplayName"

    $objReg = ObjGet("winmgmts://" & $strComputer & "/root/default:StdRegProv")
    $objReg.EnumKey $HKLM, $strKey, $arrSubkeys

    For $strSubkey In $arrSubkeys
      $intRet1 = $objReg.GetStringValue($HKLM, $strKey & $strSubkey, $strEntry1a, $strValue1)
      If $intRet1 <> 0 Then
        $objReg.GetStringValue $HKLM, $strKey & $strSubkey, $strEntry1b, $strValue1
      EndIf
      If $strValue1 <> "" Then
        $objTextFile.WriteLine $strValue1 & "¿ " & $strcomputer & "¿"
      EndIf
    Next

    $strKey2 = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
    $strEntry2a = "DisplayName"
    $strEntry2b = "QuietDisplayName"

    $objReg = ObjGet("winmgmts://" & $strComputer & "/root/default:StdRegProv")
    $objReg.EnumKey $HKLM, $strKey2, $arrSubkeys

    For $strSubkey In $arrSubkeys
      $intRet2 = $objReg.GetStringValue($HKLM, $strKey2 & $strSubkey, $strEntry2a, $strValue2)
      If $intRet2 <> 0 Then
        $objReg.GetStringValue $HKLM, $strKey & $strSubkey, $strEntry2b, $strValue2
      EndIf
      If $strValue2 <> "" Then
        $objTextFile.WriteLine $strValue2 & "¿ " & $strcomputer & "¿"
      EndIf
    Next

    $objTextFile.Close
EndIf
Edited by BoogY

Share this post


Link to post
Share on other sites

Its giving me this error :

E:\PERSO\Scripts\au3\Projects\PC Scanner\lib.au3 (123) : ==> The requested action with this object has failed.:
$objReg.EnumKey $HKLM, $strKey, $arrSubkeys
$objReg.EnumKey ^ ERROR
>Exit code: 1    Time: 0.537

I dont know if its ok how i change the script in this part

Share this post


Link to post
Share on other sites

Change $objReg.EnumKey $HKLM, $strKey, $arrSubkey to $objReg.EnumKey($HKLM, $strKey, $arrSubkey)

Share this post


Link to post
Share on other sites

i dit'it but still the same error

Share this post


Link to post
Share on other sites

HKLM is not the string representation of the hexadecimal value but 0x80000002. More here

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0