Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
Zeptal jsem se strejdy a cituji jeho první odkaz: Using the add-on tool Setx.exe It is not part of…
anarchist 21.07.2007 19:43
anarchist
Stejně ale musím nějak udělat přidávání ne proměnných, ale záznamů konkrétní proměnné, oddělených st… poslední
angel333 21.07.2007 23:49
angel333

Zeptal jsem se strejdy a cituji jeho první odkaz:

Using the add-on tool Setx.exe
It is not part of the standard Windows XP setup but a command-line tool called setx.exe is included in the Windows XP Service Pack 2 Support Tools. This tool extends the set command so that permanent changes in the environment variables can be made. For example, to add a folder C:\New Folder to the path, the command would be
setx path "%PATH%;C:\New Folder"

Scripts for Listing Environment Variables
The "Set" command can be used in a command prompt together with a redirection to a text file to make a list of the current environment variables. The command might be
set > C:\env_list.txt file
The file name "C:\env_list.txt" can be replaced by any of your choice.

Microsoft also has a VBScript that lists environment variables on this page.

Registry Keys for Environment Variables
For those who are experienced with editing the Registry, there is another way to make changes in environment variables. User environment variables are stored in the Registry in the key

HKEY_CURRENT_USER\Environment

System variables are found in the key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Cont rol\Session Manager\Environment

Note that any environment variable that is in the form that needs to be expanded (for example, %PATH%) must be stored in the registry as a REG_EXPAND_SZ registry value. Editing the Registry is primarily for scripts used by systems administrators and is not recommended for the average PC user.

Stejně ale musím nějak udělat přidávání ne proměnných, ale záznamů konkrétní proměnné, oddělených středníkem (%PATH%). To dělají některé instalátory, které potřebují, aby nainstalované binárky/skripty byly spustitelné z konzole, nebo pomocí [Okno]+[R]. Myslel jsem, že něco podobného se dá ve Windows nějak pohodlně řešit. Představoval jsem si třeba nějak takto:

setx /x path "c:\bin"

Nebo v tom VBS:

Trida.Trida.Environment.Item("Path").Add("c:\bin")

(VBS neznám, tohle je jen pro ilustraci, možná je to syntakticky špatně)

Nejspíš to bude asi jenom v installerech. Nicméně ten skriptík, co jsem si napsal, funguje. Blbý je, že teoreticky, kdyby

PATH = %windir%;%sysdir%;c:\bin;c:\binX

a já bych chtěl pomocí skriptu vymazat c:\bin, vymazalo by se mi i c:\binX. Další věc je, že kdyby

PATH = c:\bin;%windir%;%sysdir%

a opět bych chtěl c:\bin vymazat, nenašlo by ho to. No, neva, vím, že asi není správný takle uvažovat, ale pravděpodobnost, že se to stane, je malá :-).

Zpět do poradny Odpovědět na původní otázku Nahoru