in reply to Update HomeDirectory Using Win32::Ole

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.

Replies are listed 'Best First'.
Re^2: Update HomeDirectory Using Win32::Ole
by bart (Canon) on Jun 07, 2005 at 05:16 UTC
    HomeDirectory is proably a property, not a method, so
    $User->HomeDirectory("\\server\homeshare");
    should be
    $User->{HomeDirectory} = "\\\\server\\homeshare";
    Win32::OLE uses a lot of AUTOLOAD magic, so both might be exchangeable. Well, at least, I do think the accessor version of the property without parameters, is equivalent to just reading the property:
    $home = $User->HomeDirectory();
    vs.
    $home = $User->{HomeDirectory};