Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How to get the file owner on a Windows OS

by kevyt (Scribe)
on Aug 16, 2014 at 00:36 UTC ( [id://1097630]=perlquestion: print w/replies, xml ) Need Help??

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

Do you know how to get the username of the person who placed a file in a directory?

This link mentions that ActivePerl does not have "getpwuid"
http://docs.activestate.com/activeperl/5.10/faq/Windows/ActivePerl-Winfaq5.html#Certain_functions_don_t_seem_to_

This code only prints a 0 for the uid.

use File::stat; use User::pwent; my $file = 'C:\dev\test.txt'; $stat = stat( $file ); print "User id = " . $stat->uid . "\n"; print "Time = " . $stat->mtime . "\n"; use Win32::OLE; my $objShell = Win32::OLE->CreateObject("Shell.Application"); my $objFolder=$objShell->Namespace("c:\\dev") or die "$!" ; my $a = $objFolder->ParseName("test.txt") or die "$!" ; print $objFolder->GetDetailsOf($a, 8) or die "$!" ;


Thank you,
Kevin

Replies are listed 'Best First'.
Re: How to get the file owner on a Windows OS
by Anonymous Monk on Aug 16, 2014 at 00:53 UTC
      Thanks. I went to one of the links and found where someone also mentioned ways to do this with C.
        So, doing it in C worked for your or? ::)
Re: How to get the file owner on a Windows OS
by locked_user sundialsvc4 (Abbot) on Aug 16, 2014 at 11:26 UTC

    Well, first of all, Windows doesn’t really have a “uid.”   It’s a Unix/Linux concept (mostly “from the olden dayes of yore” even there), that Perl dutifully tries to emulate.   More or less . . .

    So, in the Windows world, you really do have to do it the Windows way, as others have shown you how to do.   It can be a pain for cross-platform coding, heh, but that’s not the apparent issue here.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1097630]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (1)
As of 2026-01-17 17:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (121 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.