Jump to content

VBS/Com Translation


exodius
 Share

Recommended Posts

Can someone help me with translating this? I got as far as below, but I got hung up on what some of the syntax should be...

computer="USC000012WKSS27"
set wmi = getobject("winmgmts://" & computer)
wql = "select * from win32_computersystem"
set results = wmi.execquery(wql)
for each o in results:set comp = o:exit for:next
if isnull(comp.username) then
msgbox "nobody home;-)..."
else
msgbox comp.username
end if

$computer="USC000012WKSS27"
$oWmi = ObjGet("winmgmts://" & $computer)
wql = "select * from win32_computersystem"
set results = wmi.execquery(wql)
for each o in results:set comp = o:exit for:next
If isnull(comp.username) Then
      MsgBox (0, "", "nobody home)
Else
      MsgBox (0, "", comp.username)
EndIf
Edited by exodius
Link to comment
Share on other sites

****Tested OK*****

$computer = "USC000012WKSS27"  ; this needs to be "YOUR" computer name

$oWmi = ObjGet("winmgmts://" & $computer)
$wql = "select * from win32_computersystem" 
$results = $oWmi.execquery ($wql)

For $result In $results
    If ($result.username) = "" Then
        MsgBox(0, "", "nobody home", 2)
    Else
        MsgBox(0, "", $result.username, 2)
    EndIf
Next

8)

NEWHeader1.png

Link to comment
Share on other sites

****Tested OK*****

$computer = "USC000012WKSS27"  ; this needs to be "YOUR" computer name

$oWmi = ObjGet("winmgmts://" & $computer)
$wql = "select * from win32_computersystem" 
$results = $oWmi.execquery ($wql)

For $result In $results
    If ($result.username) = "" Then
        MsgBox(0, "", "nobody home", 2)
    Else
        MsgBox(0, "", $result.username, 2)
    EndIf
Next

8)

Awesome, that works for me too, thanks Valuater!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...