Sign in to follow this  
Followers 0
XBiLe

VBS objWmiService?

7 posts in this topic

just want to know if you have this ability inside AutoIT, the name resolve from ip doesnt work on inet.au3

set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strcomputer & "\root\cimv2") 
    Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") 
        For Each objComputer in colSettings 
            CompName = objComputer.Name 
            UserName = objComputer.UserName 
            Next

Just curious guys, need some in depth functionality thanks!

-X BiLe

Share this post


Link to post
Share on other sites



maybe this will help you

ComputerInfo UDF


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

Well, there's @UserName and @ComputerName macros.. If you want to use WMI though:

Dim $strcomputer = "."

Dim $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strcomputer & "\root\cimv2") 
Dim $colSettings = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem") 
    
For $objComputer in $colSettings 
    $CompName = $objComputer.Name 
    $UserName = $objComputer.UserName 
Next

msgbox(1,"","Computer Name: " & $CompName & @CRLF & _
            "Username: " & $UserName)

; Or, without WMI
msgbox(1,"","Computer Name: " & @ComputerName & @CRLF & _
            "Username: " & @UserName)

Share this post


Link to post
Share on other sites

the reason for using the WMI is because the remote functionality of AutoIt doesnt allow for pulling remote user info on a network, but thanks for showing the WMI control, that will help writing alot of code.

you guys rock thanks for the reply! :) :)

Share this post


Link to post
Share on other sites

Hello,

i tried to find a way to get some Wmi informations, but it doesn't work.

i got a code in this forum and upgraded it to become a multiple servers connector. See this.

It need 2 files : cfgconst.ini and serverslist.ini. Just creat them before launch the Au3.

#include <file.au3>
#NoTrayIcon
$share = IniRead("cfgconst.ini", "Partage", "key", "NotFound")
$user = IniRead("cfgconst.ini", "User", "key", "NotFound")
;$pwd = IniRead("cfgconst.ini", "Pwd", "key", "NotFound")
$nb = IniRead("cfgconst.ini", "NbServeurs", "key", "NotFound")
$replog = IniRead("cfgconst.ini", "Replogs", "key", "NotFound")
If FileExists("cryptage.ini") Then
    $PASSKEY = "PASSWORD"
    $M_PASSWORD =IniRead("cryptage.ini","program","password","")
    $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD))
Else
    $PASSKEY = "PASSWORD"
    $PASSWORD=InputBox("Prompt","Password to register ? : ","","*")
    $TEMP = Str2Hex(Crypt($PASSKEY,$PASSWORD))
    IniWrite("cryptage.ini","program","password",$TEMP)
    $PASSWORD=InputBox("Prompt","Password again to verify : ","","*")
    $M_PASSWORD =IniRead("cryptage.ini","program","password","")
    $M_PASSWORD = Crypt($PASSKEY,Hex2Str($M_PASSWORD))
    If $M_PASSWORD == $PASSWORD Then
        MsgBox(0,'Ok', "Passwords match !")
    Else
        MsgBox(16,'Waouw !!!', "Passwords don't match !")
        FileDelete("cryptage.ini")
        Exit
    EndIf
EndIf
Func Crypt($PASS, $STRG)
    $A = 1
    $N_STRG = ""
    For $I = 1 To StringLen($STRG)
        $B = Asc(StringMid($PASS, $A, 1))
        $A = $A + 1
        If $A > StringLen($PASS) Then $A = 1
            $N_STRG = $N_STRG & Chr(BitXOR(Asc(StringMid($STRG, $I, 1)),$B))
    Next
    Return $N_STRG
EndFunc
Func Str2Hex($STRG)
    $H = ""
    For $I = 1 To StringLen($STRG)
        $H = $H & String(Hex(Asc(StringMid($STRG, $I, 1)),2))
    Next
    Return $H
EndFunc
Func Hex2Str($H)
    $STRG = ""
    For $I = 1 To StringLen($H) Step 2
        $STRG = $STRG & Chr(Dec(StringMid($H, $I, 2)))
    Next
Return $STRG
EndFunc
Opt("RunErrorsFatal", 1)
Opt("MustDeclareVars", 1)
main()
Func main()
Local $cmd
Local $result
Local $msg
For $i=1 to $nb
    Local $serv
    $serv = IniRead("serverslist.ini", "Server" & $i, "key", "NotFound")
    Run('net use ' & $serv & $share & ' /USER:' & $user & " " & $M_PASSWORD, @tempDir, @SW_HIDE)
    $result = RunWait(@ComSpec & " /c " & $cmd, "")
    If $result <> 0 Then
        ConsoleWriteError("Erreur : RunWait() returned error code : " & $result & @CRLF)
    EndIf
    ConsoleWrite($cmd & @CRLF)
Next
EndFunc

Share this post


Link to post
Share on other sites

@Olivertwistcoder

I could be me .. but i don't see any WMI code !


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites

Your right, there isn't any there. Secondly, he should be starting a new topic..

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