in reply to How do you Map & Disconnect Network Drives (in Windows)?

The RESOURCE_REMEMBERED, RESOURCETYPE_DISK, etc. is NOT supposed to be a string! It's a constant, so drop the singlequotes. There's also no point in putting doublequotes aroung variables, this is Perl, not shell! So 'LocalName'    =>  $LocalDrive, not 'LocalName'    =>  "$LocalDrive",. On the other hand, if you use singlequotes, then variables are not interpolated into strings, try to print the $UserName !!!

You might want to have a look at Win32::FileOp. I think it has a more Perlish interface.

Replies are listed 'Best First'.
Re^2: How do you Map & Disconnect Network Drives (in Windows)?
by perlofwisdom (Pilgrim) on Mar 26, 2008 at 15:02 UTC
    I've dropped the unnecessary quotes as you suggested. I have a really stupid question though: where do these constants derive their values? I wanted to see what their values were, so I printed them out, and got this:
    key DisplayType=3 key Scope=3 key Type=1 key Usage=2
    I had a look at the FileOp module, and it looks like it would do just what I need. Unfortunately, it takes an act of congress to deploy a module that isn't part of the standard install around here -- so I'll get the paperwork started. By the way didn't you write FileOp?

      Yes, I did write Win32::FileOp :-)

      The constants are defined within Win32::NetResource. They are defined in the XS (C with some Perl-specific macros) part of the module. And originaly they are defined by Microsoft somewhere in their C header files.