WinPE and System environment variables



Ravi
07-10-2005, 02:16 AM
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

WM
07-10-2005, 02:16 AM
Did you build in WMI support when building your WinPE image? It should work
regardless of what boot method you use.

"Ravi" <ravikanth.chaganti@gmail.com> wrote in message
news:1116514213.439986.50150@g43g2000cwa.googlegroups.com...
> 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
>

Ravi
07-10-2005, 02:16 AM
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

WM
07-10-2005, 02:16 AM
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.



"Ravi" <ravikanth.chaganti@gmail.com> wrote in message
news:1116522199.063097.115710@o13g2000cwo.googlegroups.com...
> 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
>

Ravi
07-10-2005, 02:16 AM
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?

Ravi
07-10-2005, 02:16 AM
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

Mats
07-10-2005, 02:16 AM
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

"Ravi" <ravikanth.chaganti@gmail.com> wrote in message
news:1116594962.402814.314650@g49g2000cwa.googlegroups.com...
> 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?
>


WinPE and System environment variables