WinPE and System environment variables

  • Thread starter Thread starter Ravi
  • Start date Start date
R

Ravi

All,

I had created a WinPE ISO image from my Windows OPK and using this a
RAMDISK through RIS. I want to use this for OS deployments. Now, for
automation purpose, I wrote a small script to capture the system model
and export it as a system environment variable. Here is the script:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")

'Get System Model
Set SystemSet = GetObject("winmgmts:").InstancesOf
("Win32_ComputerSystem")
for each System in SystemSet
system_model = Trim(System.Model)
next
'Set the environment variable
WshSysEnv("SysModel") = system_model

This script works as expected on my notebook (Windows XP). Within my
WinPE image, I can capture the System Model but it is not getting
exported as a system variable.

I am suspecting the read-only nature of the WinPE as it is loaded from
ISO file.

Any ideas how I can make this work?

Thanks for your time,
Ravi
 
Did you build in WMI support when building your WinPE image? It should work
regardless of what boot method you use.
 
Yes. I did.
In fact, within WinPE image itself, system model is displayed correctly
using WScript.Echo system_model. I had enabled WSH and HTA support
also.

Ravi
 
Interesting. I could have sworn I've set env vars before when running from
CD - but via SET, not via WshSysEnv - I actually always thought that was RO.

Have you tried running wshshell.exec and using SET to set the variable?
There may be a missing dependency in the WshSysEnv component.

The fact that you are running as LocalSystem instead of as a user may also
cause some problematic behavior.
 
I got the problem.
when I set a environment variable using WSH or WMI, I have to access
that variable using the same mechanism. echo %SysModel% at command
prompt will not work which makes sence to me as we didnot use SET to
define this environment variable.

I need to do something like this in the other script:
WScript.Echo WshSysEnv("SysModel")
What is your opinion?
 
My initial post did not specify how I tried accessing the variable.
Also, I had mentioned that it worked on my notebook. Two misleading
statements.

Sorry for that

Ravi
 
You might have to set up a ramdrive and use a textfile on that. We had
similar problems with pe 1.1 and went the ramdrive way
 
Back
Top