Page 1 of 1 1
Topic Options
#91613 - 2003-02-27 04:39 PM wmi wont run as SYSTEM?
rollo Offline
Getting the hang of it

Registered: 2000-07-11
Posts: 85
Loc: louisiana
hello,
I use the following code
in our logon to gather info.
works GREAT!
I also use norton system center to push out jobs
with same code,
when it runs the job, it runs as user "system"
But the script bombs out.
I am not sure if the impersonate thing is what
is problem is.
any help would be appreciated.
if this is off topic I apologize.
thanks
Adam
code:
  BREAK ON 

$Manufacturer = WMIQuery("Manufacturer","Win32_ComputerSystem")
$SystemModel = WMIQuery("Model","Win32_ComputerSystem")
$SystemSerialNumber = WMIQuery("SerialNumber","Win32_BIOS")
$CPUManufacturer = WMIQuery("manufacturer","Win32_Processor")
$SystemMemory = val(WMIQuery("TotalPhysicalMemory","Win32_LogicalMemoryConfiguration"))/1024

FUNCTION WMIQuery($what,$where,)
DIM $strquery, $objenumerator, $value
$strquery = "Select $what From $where"
$systemset = GetObject("winmgmts:{impersonationLevel=impersonate}!//@WKSTA")
$objenumerator = $systemset.execquery($strquery)
FOR EACH $objinstance IN $objenumerator
IF @error = 0 AND $objinstance <> ""
$=execute("$$value = $$objInstance.$what")
$wmiquery="$value"+"|"+"$WMIQuery"
ENDIF
NEXT
$wmiquery=left($wmiquery,len($wmiquery)-1)
EXIT @error
ENDFUNCTION

return


Top
#91614 - 2003-02-27 04:53 PM Re: wmi wont run as SYSTEM?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uh, wmi.
and vars in strings.
and $-var not dimmed.
and...
and...

quess this might be a place for shell-object.
_________________________
!

download KiXnet

Top
#91615 - 2003-02-27 05:06 PM Re: wmi wont run as SYSTEM?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
The SYSTEM account has a lot of restricitions, e.g. no network access. It's better to run administrative scripts under an administrative account.

[ 28. February 2003, 03:18: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#91616 - 2003-02-27 05:34 PM Re: wmi wont run as SYSTEM?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Is that a RETURN without GOSUB?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#91617 - 2003-02-27 06:11 PM Re: wmi wont run as SYSTEM?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
there is no gosub.
but, that does not bomb the script, sure for that.
_________________________
!

download KiXnet

Top
#91618 - 2003-02-27 06:22 PM Re: wmi wont run as SYSTEM?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
He also posted only part of his script. And he needs to learn to be more precise when describing problems.

User: "The script bombs out!"
Tech Support: "We'll notify the bomb squad, they'll defuse it!"

[ 27. February 2003, 18:22: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#91619 - 2003-03-03 03:31 PM Re: wmi wont run as SYSTEM?
rollo Offline
Getting the hang of it

Registered: 2000-07-11
Posts: 85
Loc: louisiana
[Confused]
I got it working with user system I changed the line. from this
code:
 $systemset = GetObject("winmgmts:{impersonationLevel=impersonate}!//@WKSTA") 

to this
code:
 $systemset = GetObject("winmgmts:\\.") 

I also dimmed the vars this all seemed to fix it

[ 03. March 2003, 15:34: Message edited by: rollo ]

Top
#91620 - 2003-03-03 08:27 PM Re: wmi wont run as SYSTEM?
NTDOC Administrator Online   content
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Rollo,

This should work as well, and allows you to select the computer you want to use in case you want to run it as an Admin script.



$computer=@WKSTA
$systemset  = GetObject("winmgmts:" + "{impersonationLevel=impersonate}!\\" + $computer + "\root\cimv2")



[ 03. March 2003, 20:28: Message edited by: NTDOC ]

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.035 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org