treebug has asked for the wisdom of the Perl Monks concerning the following question:

how can i get a list of usernames from an windows xp box im sure there is a more efficient way than getting a dir of the c:\documents and settings\ folder and sorting the output i am new to perl and trying to automate deleting all of my user's temporary internet files and temp files from their c:\docs and sets\usrname\local settings\ folder thanks

Replies are listed 'Best First'.
Re: windows xp list users
by BrowserUk (Patriarch) on Jun 28, 2005 at 01:09 UTC

    See Win32::NetAdmin::GetUsers()...


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re: windows xp list users
by davidrw (Prior) on Jun 28, 2005 at 01:07 UTC
    If deleting the temporary internet files is your only requirement, then there's no need to know the actual user list -- you can simply just find (File::Find) and delete c:\documents and settings\*\local settings\Temporary Internet Files\* or whatever the wildcard is.

    To find the actual users, i'm not sure -- i find out how to do that in general first, and then use that as a guide to find the right Win32 module. (Or maybe it's an external command you can backtick)
    Update: Doh -- i cpan-searched for "Win32::Admin" .. BrowserUK found the right one at Win32::NetAdmin .
Re: windows xp list users
by eyepopslikeamosquito (Archbishop) on Jun 28, 2005 at 07:43 UTC

    There is also Win32::Lanman. In particular:

    Win32::Lanman::NetUserGetInfo Win32::Lanman::NetGroupEnum Win32::Lanman::NetGroupGetUsers Win32::Lanman::NetGetDCName
    However, it disturbs me that Win32::Lanman, though powerful and comprehensive, is not on CPAN. Anyone know why?

      However, it disturbs me that Win32::Lanman, though powerful and comprehensive, is not on CPAN. Anyone know why?

      It's there, the source package just doesn't contain the data that CPAN needs in order to index it. You can find it in the authors/id/J/JH/JHELBERG/ directory though. Maybe someone needs to reach out to the author and create at least a META.yml file for them to include that would let it get indexed.


      We're not surrounded, we're in a target-rich environment!