View Single Post
  #7  
Old July 27th 13, 04:40 AM posted to microsoft.public.win98.gen_discussion
R.Wieser
External Usenet User
 
Posts: 111
Default Adding a persistent environment variable. How ?

Hello Hot-Text,

Article ID: 188135 - Last Review: August 9, 2007 - Revision: 3.6


I'm sorry if I was not clear about it.

The problem is *not* the scripting host, but how to add environment
variables to an *already-existing* environment (so that it and all
environments created after it have the newly-added enviroment variables
too).

In my case its just duplicating the, for example, current computer name into
an environment-variable. So that any program/console-window will see it.

Regards,
Rudy Wieser


-- Origional message:
Hot-Text schreef in berichtnieuws
...
"98 Guy" wrote in message ...
"R.Wieser" wrote:
Hello 98 Guy,
Are you looking for a method to do that under win-9x?
Yep. That is why I did post the question here and not in, for
example microsoft.public.windowsxp.help_and_support. :-)

It wasn't a dumb question.
This wouldn't be the first time that someone (a non-regular) shows up
here with a question that wasn't intended for win-9x/me.
I don't believe that win-9x supports any of the above types
except for "process", as mentioned he snip link
Well, I can store and retrieve from those sections


The Windows Scripting Hosts does not support System, User and Volatile
environment variable catagories under Win-9x/me - only the Process
type. I'm not even sure if they exist under 9x, or where they are
stored. Where are you storing / retrieving them from? The Registry?


http://support.microsoft.com/kb/188135
Article ID: 188135 - Last Review: August 9, 2007 - Revision: 3.6
APPLIES TO
Microsoft Windows 95
Microsoft Windows 95
Microsoft Windows 98 Standard Edition
Microsoft Windows 98 Standard EditionKeywords: kbinfo KB188135

Installing Windows Script Host
To install the Windows Script Host, please see the following Microsoft Web
site:
http://msdn2.microsoft.com/en-us/library/ms950396.aspx
NOTE: Windows Script Host is included in Microsoft Internet Explorer 5.


Any idea if I can add to the "process" environment by other means

(from
within a VBScript (or program) ) ?

Did you even look at this link?
http://wsh2.uw.hu/ch07c.html
=============
Accessing Environment Variables in a Script
One use for environment variables is to tell the script what platform
(Intel or Alpha) the code is executed on. You can also determine which
operating system (Windows 98 or Windows 2000) is being used. But you
must be careful because, as just mentioned, Windows 2000 environment
variables are different from environment variables in Windows 95 and
Windows 98.
How do you access the environment variables in a script? To access
environment variables on a particular system, you can use the
Environment property of the WshShell object, which returns the
WshEnvironment collection object. According to the Windows Script Host
Reference, the Environment property has the following syntax:
object.Environment([strType])
The index strType specifies the category in which the environment
variable resides. In Windows NT and Windows 2000, the operating system
groups environment variables internally into the System, User, Volatile,
and Process categories, so you can use the "System", "User", "Volatile",
or "Process" string as the index. In Windows 95 and Windows 98, the
method supports only the "Process" entry. If you omit the index value,
the method retrieves the environment variables from the System category
in Windows NT or Windows 2000. In Windows 95 and Windows 98, the method
retrieves the Process environment variables because Process is the only
category supported.
Table 7-3 describes some of the environment variables the operating
system sets.
You can use the following statements to access the Environment property:
Set WshShell = CreateObject("WScript.Shell")
Set objEnv = WshShell.Enviroment("Process")
The first line creates a reference to the WshShell object and stores it
in the object variable WshShell. The next statement uses this object
variable to access the Environment property. The parameter specifies the
category in which the environment variables reside. Environment returns
a collection object, so you must assign the result to an object variable
by using the Set statement. (The items in the collection are the values
of the environment variables in the category.)
This next line retrieves the value of a specific environment variable:
Text = objEnv("PATH")
This statement requires that objEnv contain a collection obtained from
the Environment property. The index for the objEnv object must contain
the name of an environment variable. The preceding statement assigns the
value of the environment variable PATH to the variable Text.
=====================
Plenty more material there that I did not quote.