Jump to content
Sign in to follow this  
exodius

VBS/Com Translation

Recommended Posts

exodius

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

Share this post


Link to post
Share on other sites
Valuater

****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

Share this post


Link to post
Share on other sites
Valuater

Last Seen: 40 minutes ago

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
exodius

****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!

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  

×