Setting an environment variable via GPO or other method? (Depends on OS type, 64 or 32bit) ?

M

markm75

I need a way to set an environment variable based on the type of OS
installed.. ie: If the OS is 32bit only, then I need to set an
environment variable %ProgramFilesx86%= "" (blank), if the envronment
is 64bit, then I want something like %ProgramFilesX86"= the x86 path
here...

The reason for this is a coding language used in an application cannot
handle the "(x86)" part of the default environment variables.. there
is no way around it.. so the only way is to create a new environment
variable

Does anyone know of a way to do this via GPO.. or is there some other
way that wouldnt involve a GPO?

If I try this during the login script, it gets lost after the
login.bat window closes...

This needs to stay in "memory" while the OS is running, after the
login script..

(I've seen some examples of doing environment variables via GPO ADM
templates, but I'm not sure how to make it dynamic based on if the
program files (x86) folder exists or not)

Any help would be great.

Thanks
 
G

Guest

If i remember my GPO and AD corretly.

you are going to have to put each type of system in it's own 'folder' on ADUC.
Tthen assign a Policy for that folder.
 
M

markm75

If i remember my GPO and AD corretly.

you are going to have to put each type of system in it's own 'folder' on ADUC.
Tthen assign a Policy for that folder.

--
Psudo36
MCP (WinNT4, Win2K, WinXP)












- Show quoted text -

Well I did find this code:

Option Explicit

Dim objWMI
Dim colClass
Dim objClass

Dim strComputer

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colClass = objWMI.ExecQuery("Select * from Win32_Processor",,48)

WScript.Echo "Query: Win32_Processor::AddressWidth"
On Error Resume Next

For Each objClass in colClass
WScript.Echo "AddressWidth: " & objClass.AddressWidth
Next

Set objWMI = Nothing
Set colClass = Nothing
Set objClass = Nothing

This will show 32 for xp and 64 for xp x64 etc..

I'm not sure how to do the whole WMI filter in Group Policy
management..

When I add the code it says:


"A syntax error occurred tyring to evaluate a query string"

Somehow this whole code needs result in 32 or 64 and be checkable via
the wmi filter?
 
M

markm75

Well I did find this code:

Option Explicit

Dim objWMI
Dim colClass
Dim objClass

Dim strComputer

strComputer = "."
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colClass = objWMI.ExecQuery("Select * from Win32_Processor",,48)

WScript.Echo "Query: Win32_Processor::AddressWidth"
On Error Resume Next

For Each objClass in colClass
WScript.Echo "AddressWidth: " & objClass.AddressWidth
Next

Set objWMI = Nothing
Set colClass = Nothing
Set objClass = Nothing

This will show 32 for xp and 64 for xp x64 etc..

I'm not sure how to do the whole WMI filter in Group Policy
management..

When I add the code it says:

"A syntax error occurred tyring to evaluate a query string"

Somehow this whole code needs result in 32 or 64 and be checkable via
the wmi filter?- Hide quoted text -

- Show quoted text -

Actually I believe this is simpler:

I tried this and the wmi gpo filter accepted it:

Select * from Win32_Processor where AddressWidth ='32'

So there would be one for 32 and one for 64...

Combining that with an adm template inside a seperate policy should do
the trick I think.
 
M

markm75

Actually I believe this is simpler:

I tried this and the wmigpofilter accepted it:

Select * from Win32_Processor where AddressWidth ='32'

So there would be one for 32 and one for 64...

Combining that with anadmtemplate inside a seperate policy should do
the trick I think.- Hide quoted text -

- Show quoted text -


I tried using an adm with this syntax:

CLASS MACHINE
CATEGORY "Env Variables"
POLICY "Set 32BIT"
KEYNAME "SYSTEM\CurrentControlSet\Control\Session Manager
\Environment"
PART "ProgramFilesx86"
EDITTEXT
VALUENAME "%SystemDrive%:\Program Files"
DEFAULT ""
END PART
END POLICY
END CATEGORY

But all i seem to see in the GPO object is "Env Variables"...
 
M

markm75

I tried using an adm with this syntax:

CLASS MACHINE
CATEGORY "Env Variables"
POLICY "Set 32BIT"
KEYNAME "SYSTEM\CurrentControlSet\Control\Session Manager
\Environment"
PART "ProgramFilesx86"
EDITTEXT
VALUENAME "%SystemDrive%:\Program Files"
DEFAULT ""
END PART
END POLICY
END CATEGORY

But all i seem to see in the GPO object is "Env Variables"...- Hide quoted text -

- Show quoted text -

I found a setting under filtering I had to uncheck to be able to see
the newly added adm area in the GPO..

Problem I have now is this:



I want to set a new variable such as ProgramFilesx86 (note the lack of
parenthesis) = c:\program files if 32bit and c:\program files (x86) if
64bit..

but I need that c drive to be variable.. ie: reflect %systemdrive%
instead...

If I put %systemdrive% in the GPO adm template.. it just remains in
that form for the environment variable value.. ie: it doesnt become
C: or G: etc..

Any ideas on how to do this part?
 

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