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

Hello 98 Guy,

It wasn't a dumb question.


It wasn't.

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.


As I'm not a regular member of this newsgoup I can not other than to agree
to that possability (and "http://notalwaysright.com/" bears me out on that).

Alas, I'm an "old hand" at posting questions like these (which you could not
have known, but should also not have presumed otherwise), so I sought for
and selected this newsgroup on purpose (as I humorously tried to mention)

Did you even look at this link? snip link


As my browser has changed the appearance of that link to "already visted" I
must assume that I did (I visited *many* links in the hours I trie to find
an answer myself). And re-following it appears that I certainly did do so.

Accessing Environment Variables in a Script bla bla bla


I read all that. As its claims do not in any way match my own tests (which
I already mentioned) I cannot other than discard them (until some more
substanciation is provided). Sorry.

My question to you: have you read my previous reply, and why are you
ignoring my testresults ? You may be *the* authority on this plane (are
you?), but that does not make you infallible.



If I might seem too straight-forward than my apologies. I'm not really
accustomed to someone discarding my *posted findings* without even
challenging them. Personally I would call that rude (to say the least).
Regards,
Rudy Wieser


-- Origional message
98 Guy schreef in berichtnieuws ...
"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?

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.