Running Windows WMI Query as Different User...
by jpantera other posts by this author
Jul 20 2006 4:45PM messages near this date
view in the new Beta List Site
Re: Fw: cgi-perl: embedding javascript in cgi-perl
|
TieRegistry and 64 bit registry (x64)
Hello. Looking for some assistance on setting up my Win32 perl script that does WMI Query,
so that is runs as a specified user (not the user who will fire off the script). Wrote a ve
ry crude VBScript program a while ago that worked (but need to re-write in perl) and it did
the following... Setup variables for the Admin user I intended to use, for their username a
nd password, then fed the WMI query through the following VBScript function (worked fine):
Working VBScript Method:
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer _
(sComputer, "root\cimv2", strUser, strPassword)
(Where "sComputer", "strUser" and "strPassword" were the string variables containing the com
puter name, username and password)
Can't seem to find the same functionality in perl... Tried to append the same type of varia
bles to my (working) call:
my $objWMIService = Win32::OLE-> GetObject("winmgmts:\\\\$sComputer\\root\\CIMV2") or warn "W
MI connection failed: $!\n";
Changing it to:
my $objWMIService = Win32::OLE-> GetObject("winmgmts:\\\\$sComputer\\root\\CIMV2\\$strUser\\$
strPassword") or warn "WMI connection failed: $!\n";
but does not allow. Has anyone done this? Need script to run as specified user.
- Joe Pantera, Admin / DBA
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joseph F. Pantera System, Database & Network Administrator
Gibson Dunn & Crutcher LLP
work mail: jpantera@[...].com
home mail: jpantera@[...].net
phone: (213) 229-7673
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
|