Jump to content

getting infos on the current user


dizi
 Share

Recommended Posts

hi,

i'm having trouble using AutoIT to get the name of the current user. Let me explain ...

We use a package deployment solution named OCS ( http://www.ocsinventory-ng.org/ ). It's the OCS client, installed on all our computers, who launch our AutoIT packages. The OCS agent is launch automatically by the service manager.

In one of our package, we need to know who is the current user, so we used the @Username macro. When manually launched the result is OK, it's the name of the current user. But when launched via the OCS agent, the result is "SYSTEM".

So we tried with @UserProfileDir: ok when launched manually, but with OCS the result is "C:\Documents and Settings\LocalService".

We also tried to get the result of the DOS command "echo %USERNAME%" ... same conclusion : it worked well manually, but it returns "SYSTEM" with the OCS agent ...

By chance, any idea ?

Any help will be grealty appreciated :]

Edited by dizi
Link to comment
Share on other sites

hi,

i'm having trouble using AutoIT to get the name of the current user. Let me explain ...

We use a package deployment solution named OCS ( http://www.ocsinventory-ng.org/ ). It's the OCS client, installed on all our computers, who launch our AutoIT packages. The OCS agent is launch automatically by the service manager.

In one of our package, we need to know who is the current user, so we used the @Username macro. When manually launched the result is OK, it's the name of the current user. But when launched via the OCS agent, the result is "SYSTEM".

So we tried with @UserProfileDir: ok when launched manually, but with OCS the result is "C:\Documents and Settings\LocalService".

We also tried to get the result of the DOS command "echo %USERNAME%" ... same conclusion : it worked well manually, but it returns "SYSTEM" with the OCS agent ...

By chance, any idea ?

Any help will be grealty appreciate :]

This is what I use:

Global $LastName = EnvGet("NWLASTNAME")
Global $FirstName = EnvGet("NWFIRSTNAME")
Global $username = EnvGet("NWUSERNAME")
Global $computername = EnvGet("COMPUTERNAME")
Global $computerlocation = EnvGet("PCLocation")

The NW ones come from Novell log-in.

If you type 'SET' in a dos box you'll see what's available to you.

William

Link to comment
Share on other sites

thanks for the tip

as always it worked well when the autoit exe is launched manually. But when it's launched whith the OCS agent, this time with EnvGet the result is null ...

i'm lost

$computername = EnvGet("USERNAME")
MsgBox(4096, "Test", $computername, 10)
Link to comment
Share on other sites

found !

$username=""
$objWMIService = Objget("winmgmts:\\localhost\root\cimv2")
$colComputer = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
;
If IsObj($colComputer) Then
    For $objComputer In $colComputer
        $username &= "username = "&$objComputer.UserName&@CRLF
    Next
Else
    MsgBox(0, "WMI Output", "No WMI Objects Found for class: " & "Win32_ComputerSystem")
EndIf

MsgBox(1, "username", $username)

twisted but it worked

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