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.