WMI Script Issue

J

JMasters

I have created a script to run after FBA that will modify the
registry to disable write caching on all of the IDE drives. It searches
the registry for IDE devices and adds the UserRemovalPolicy=3 setting
to each.
The script works fine on my XP Desktop but I am having problems
getting it to run on my XPE image. Our target size is limited so I am
trying to add as view components as possible.
Here is the script I am using:
---------------------------------------------------------------------------------
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strValueName = "UserRemovalPolicy"
dwValue = 3

strKeyPath = "SYSTEM\CurrentControlSet\Enum\IDE"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

strKeyPath2 = "SYSTEM\CurrentControlSet\Enum\IDE\" & subkey
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath2, arrSubKeys2

For Each subkey2 In arrSubKeys2

strKeyPath3 = strKeyPath2 & "\" & subkey2 & "\Device
Parameters\ClassPnP"
oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath3

oReg.SetDWORDValue
HKEY_LOCAL_MACHINE,strKeyPath3,strValueName,dwValue

Next

Next
--------------------------------------------------------------------------------

I'm not an expert at scripting. I pieced this together with some
examples I found online. The error I am getting when I run it is:
ActiveX component can't create object: "GetObject" on Line 5

Any ideas?

Thanks!
 
G

Guest

you need to add WMI support in the image, at least the "WMI Win32 Provider"
component and dependencies including "WMI Core" and "WMI Tools". Also, you
will need "WMI Scripting".

KS

This posting is provided "AS IS" with no warranties and confers no rights.
 
J

JMasters

I added the above and their dependencies and it worked fine. Just for a
test I let it run an auto-resolve dependency check. It added 80MB to my
image. My image was originally about 100MB total. The auto resolve
bloats it way too much.
I had started with just the WMI Core, scripting, tools and Win32
provider and tried to be selective on the dependencies but I haven't
been able to make it work yet. It seems to have some dependencies like
the "Microsoft Audio Compression Manager" that seem unnecesary. My
target is a headless system with no audio device. I'll trial and error
it until I can get it to work with just the needed components.
 
K

KM

The answer is simple - don't use scripting. Create a simple app in C/C++ with very minimum dependencies.

=========
Regards,
KM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top