If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Adding a persistent environment variable. How ?
Hello All,
I have the need to add an environment variable that will be visible to all processes (a fake "LOGONSERVER" for a stand-alone). I've found several ways to add them to "system", "user" and even "Volatile" sections, but found no way to add them to "process". Ultimatily I would like to be able to copy, using vbscript, a few environment variables from the "user" section to the "process" section. Any idea how to do it ? Regards, Rudy Wieser |
#2
|
|||
|
|||
Adding a persistent environment variable. How ?
"R.Wieser" wrote:
I have the need to add an environment variable that will be visible to all processes (a fake "LOGONSERVER" for a stand-alone). I've found several ways to add them to "system", "user" and even "Volatile" sections, but found no way to add them to "process". Ultimatily I would like to be able to copy, using vbscript, a few environment variables from the "user" section to the "process" section. Any idea how to do it ? Are you looking for a method to do that under win-9x? I don't believe that win-9x supports any of the above types except for "process", as mentioned he http://wsh2.uw.hu/ch07c.html For win-9x, you just need to programatically edit the autoexec.bat file to add new environment variables (and restart the system). |
#3
|
|||
|
|||
Adding a persistent environment variable. How ?
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. :-) 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, and the "system" and "user" and "volatile" sections do seem to be persistent (I just checked if the settings I stored yesterday are, after having shut down the 'puter yesterday and rebooted today, still present. They are. Even in the "volatile" section ...). For win-9x, you just need to programatically edit the autoexec.bat file to add new environment variables (and restart the system). Grmbl .... I thought I did already try that and didn't work. Just to make sure I retried just now and it did. I must have done something wrong previously. Thanks for having me retry it. :-) Any idea if I can add to the "process" environment by other means (from within a VBScript (or program) ) ? Regards, Rudy Wieser -- Origional message: 98 Guy schreef in berichtnieuws ... "R.Wieser" wrote: I have the need to add an environment variable that will be visible to all processes (a fake "LOGONSERVER" for a stand-alone). I've found several ways to add them to "system", "user" and even "Volatile" sections, but found no way to add them to "process". Ultimatily I would like to be able to copy, using vbscript, a few environment variables from the "user" section to the "process" section. Any idea how to do it ? Are you looking for a method to do that under win-9x? I don't believe that win-9x supports any of the above types except for "process", as mentioned he http://wsh2.uw.hu/ch07c.html For win-9x, you just need to programatically edit the autoexec.bat file to add new environment variables (and restart the system). |
#4
|
|||
|
|||
Adding a persistent environment variable. How ?
"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. |
#5
|
|||
|
|||
Adding a persistent environment variable. How ?
"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. |
#7
|
|||
|
|||
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. |
#8
|
|||
|
|||
Adding a persistent environment variable. How ?
"R.Wieser" wrote in message
l... 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 INCLUDE c:\windows\lmhosts.sam Do a Search for hosts Results hosts.ini lmhosts.sam lmhosts.sam # Copyright (c) 1993-1999 Microsoft Corp. # # This is a sample LMHOSTS file used by the Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to computernames # (NetBIOS) names. Each entry should be kept on an individual line. # The IP address should be placed in the first column followed by the # corresponding computername. The address and the computername # should be separated by at least one space or tab. The "#" character # is generally used to denote the start of a comment (see the exceptions # below). # # This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts # files and offers the following extensions: # # #PRE # #DOM:domain # #INCLUDE filename # #BEGIN_ALTERNATE # #END_ALTERNATE # \0xnn (non-printing character support) # # Following any entry in the file with the characters "#PRE" will cause # the entry to be preloaded into the name cache. By default, entries are # not preloaded, but are parsed only after dynamic name resolution fails. # # Following an entry with the "#DOM:domain" tag will associate the # entry with the domain specified by domain. This affects how the # browser and logon services behave in TCP/IP environments. To preload # the host name associated with #DOM entry, it is necessary to also add a # #PRE to the line. The domain is always preloaded although it will not # be shown when the name cache is viewed. # # Specifying "#INCLUDE filename" will force the RFC NetBIOS (NBT) # software to seek the specified filename and parse it as if it were # local. filename is generally a UNC-based name, allowing a # centralized lmhosts file to be maintained on a server. # It is ALWAYS necessary to provide a mapping for the IP address of the # server prior to the #INCLUDE. This mapping must use the #PRE directive. # In addtion the share "public" in the example below must be in the # LanManServer list of "NullSessionShares" in order for client machines to # be able to read the lmhosts file successfully. This key is under # \machine\system\currentcontrolset\services\lanmans erver\parameters\nullsessionshares # in the registry. Simply add "public" to the list found there. # # The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE # statements to be grouped together. Any single successful include # will cause the group to succeed. # # Finally, non-printing characters can be embedded in mappings by # first surrounding the NetBIOS name in quotations, then using the # \0xnn notation to specify a hex value for a non-printing character. # # The following example illustrates all of these extensions: # # 102.54.94.97 rhino #PRE #DOM:networking #net group's DC # 102.54.94.102 "appname \0x14" #special app server # 102.54.94.123 popular #PRE #source server # 102.54.94.117 localsrv #PRE #needed for the include # # My 3 IP addresses to computer-names 192.168.1.68 nntp.gateway.pace.com # NNTP. 192.168.1.254 gateway.pace.com # gateway. 192.168.1.64 mynews.gateway.pace.com # MYNEWS. # # #BEGIN_ALTERNATE # #INCLUDE \\localsrv\public\lmhosts # #INCLUDE \\rhino\public\lmhosts # #END_ALTERNATE # # In the above example, the "appname" server contains a special # character in its name, the "popular" and "localsrv" server names are # preloaded, and the "rhino" server name is specified so it can be used # to later #INCLUDE a centrally maintained lmhosts file if the "localsrv" # system is unavailable. # # Note that the whole file is parsed including comments on each lookup, # so keeping the number of comments to a minimum will improve performance. # Therefore it is not advisable to simply add lmhosts file entries onto the # end of this file. |
#9
|
|||
|
|||
Adding a persistent environment variable. How ?
Hello Hot-Text,
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. I'm afraid you missed the "for example" bit in the above. The idea is that I would like to be able to add/change an environment variable to the "process" group. What goes into that variable is and which name its going to get is non-important at this moment Also, would that INCLUDE add all the names I have in my host-list to the environment of all started processes ? I hope not, as I use it as a (crude) anti-spam filter (it contains a slew of names, all redirected to 127.0.0.1). :-) Regards, Rudy Wieser -- Origional message: Hot-Text schreef in berichtnieuws ... "R.Wieser" wrote in message l... 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 INCLUDE c:\windows\lmhosts.sam Do a Search for hosts Results hosts.ini lmhosts.sam lmhosts.sam # Copyright (c) 1993-1999 Microsoft Corp. # # This is a sample LMHOSTS file used by the Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to computernames # (NetBIOS) names. Each entry should be kept on an individual line. # The IP address should be placed in the first column followed by the # corresponding computername. The address and the computername # should be separated by at least one space or tab. The "#" character # is generally used to denote the start of a comment (see the exceptions # below). # # This file is compatible with Microsoft LAN Manager 2.x TCP/IP lmhosts # files and offers the following extensions: # # #PRE # #DOM:domain # #INCLUDE filename # #BEGIN_ALTERNATE # #END_ALTERNATE # \0xnn (non-printing character support) # # Following any entry in the file with the characters "#PRE" will cause # the entry to be preloaded into the name cache. By default, entries are # not preloaded, but are parsed only after dynamic name resolution fails. # # Following an entry with the "#DOM:domain" tag will associate the # entry with the domain specified by domain. This affects how the # browser and logon services behave in TCP/IP environments. To preload # the host name associated with #DOM entry, it is necessary to also add a # #PRE to the line. The domain is always preloaded although it will not # be shown when the name cache is viewed. # # Specifying "#INCLUDE filename" will force the RFC NetBIOS (NBT) # software to seek the specified filename and parse it as if it were # local. filename is generally a UNC-based name, allowing a # centralized lmhosts file to be maintained on a server. # It is ALWAYS necessary to provide a mapping for the IP address of the # server prior to the #INCLUDE. This mapping must use the #PRE directive. # In addtion the share "public" in the example below must be in the # LanManServer list of "NullSessionShares" in order for client machines to # be able to read the lmhosts file successfully. This key is under # \machine\system\currentcontrolset\services\lanmans erver\parameters\nullsessi onshares # in the registry. Simply add "public" to the list found there. # # The #BEGIN_ and #END_ALTERNATE keywords allow multiple #INCLUDE # statements to be grouped together. Any single successful include # will cause the group to succeed. # # Finally, non-printing characters can be embedded in mappings by # first surrounding the NetBIOS name in quotations, then using the # \0xnn notation to specify a hex value for a non-printing character. # # The following example illustrates all of these extensions: # # 102.54.94.97 rhino #PRE #DOM:networking #net group's DC # 102.54.94.102 "appname \0x14" #special app server # 102.54.94.123 popular #PRE #source server # 102.54.94.117 localsrv #PRE #needed for the include # # My 3 IP addresses to computer-names 192.168.1.68 nntp.gateway.pace.com # NNTP. 192.168.1.254 gateway.pace.com # gateway. 192.168.1.64 mynews.gateway.pace.com # MYNEWS. # # #BEGIN_ALTERNATE # #INCLUDE \\localsrv\public\lmhosts # #INCLUDE \\rhino\public\lmhosts # #END_ALTERNATE # # In the above example, the "appname" server contains a special # character in its name, the "popular" and "localsrv" server names are # preloaded, and the "rhino" server name is specified so it can be used # to later #INCLUDE a centrally maintained lmhosts file if the "localsrv" # system is unavailable. # # Note that the whole file is parsed including comments on each lookup, # so keeping the number of comments to a minimum will improve performance. # Therefore it is not advisable to simply add lmhosts file entries onto the # end of this file. |
#10
|
|||
|
|||
Adding a persistent environment variable. How ?
"R.Wieser" wrote in message
l... Hello Hot-Text, 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. I'm afraid you missed the "for example" bit in the above. The idea is that I would like to be able to add/change an environment variable to the "process" group. What goes into that variable is and which name its going to get is non-important at this moment Also, would that INCLUDE add all the names I have in my host-list to the environment of all started processes ? I hope not, as I use it as a (crude) anti-spam filter (it contains a slew of names, all redirected to 127.0.0.1). :-) Good move on stopping spam Regards, Rudy Wieser In Scriptomatic will help you with add/change an environment variable http://social.msdn.microsoft.com/Sea...iptomatic&ac=4 download @ http://www.microsoft.com/downloads/d...ylang=en%C2%A0 Have Fun |
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Define SYSTEMROOT variable in WinME | dook | General | 10 | June 22nd 06 07:52 PM |
Variable Bandwidth/Speed on LAN | Barnaby Falls | Networking | 0 | July 9th 04 05:02 PM |
Curious environment variable | BarryG | General | 6 | June 30th 04 09:02 AM |
Persistent crash in newbuilt system | Jim the Computer Guy | Setup & Installation | 1 | June 12th 04 10:53 AM |
Wrong audio drivers persistent | Mike Easter | General | 10 | June 9th 04 11:27 PM |