A found a few problems.
According to you VB snippet, ",user" is appended to the first string; it's not a seperate argument.
Win32::OLE->GetObject("WinNT://wsi/$username", "user");
should be
Win32::OLE->GetObject("WinNT://wsi/$username,user");
Don't forget to double backslashes in hard-coded strings.
"\\server\homeshare"
should be
"\\\\server\\homeshare"
HomeDirectory is proably a property, not a method, so
$User->HomeDirectory("\\server\homeshare");
should be
$User->{HomeDirectory} = "\\\\server\\homeshare";
Unfortunately, that doesn't seem to be enough.
use strict;
use warnings;
use Win32::OLE ();
my $user_name = 'Administrator';
my $user = Win32::OLE->GetObject("WinNT://wsi/$user_name,user")
or die("\$user is undef\n"); # <---- dies here
print($User->{HomeDirectory}, "\n");
# $user->{HomeDirectory} = "\\\\server\\homeshare";
# $user->SetInfo;
But that's probably cause I'm not running a compatible platform. MSDN says this interface is only available on Windows 2000 Server and Windows Server 2003, which I don't have.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|