Jump to content

Help to finish converting a small VB


Recommended Posts

This a script to obtain the logged on user when running as a service.

Since @username would just return System

I'd appreciate any help converting this I think it's close.

Thanks,

Kenny

Here's what I have been able to figure out

;Converted to AutoIT
Local $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
Local $User = $objWMIService.GetOwner("processDomain, processUser")
MsgBox(0,"",$User)

Here's the original I found online

Dim mc As New ManagementClass("Win32_Process")
Dim moc As ManagementObjectCollection = mc.GetInstances
Dim mo As ManagementObject
Dim processDomain, processUser As String
 For Each mo In moc
     Dim p As New ROOT.CIMV2.Process(mo)
     p.GetOwner(processDomain, processUser)
       If (p.Name.Trim = "explorer.exe") Then
          Return processUser
          Exit For
       End If  
 Next

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

$strComputer = "."
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

$objEnum = $objWMIService.ExecQuery("select __relpath from win32_process where caption = 'explorer.exe'")

for $obj in $objEnum
        $outParams = $obj.ExecMethod_("GetOwner")
        ConsoleWrite("User: " & $outParams.User & " is currently logged in on computer " & $strComputer & "." & @CRLF)
next

Link to comment
Share on other sites

well obviously my attempt was way off lol

thanks :)

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

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