2
19
2010
8

环境变量

 REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f]

KeyName [\\Machine\]FullKey
           远程机器的机器名 - 忽略默认到当前机器。
                    远程机器上只有 HKLM 和 HKU。
           FullKey ROOTKEY\SubKey
           ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
           SubKey   所选 ROOTKEY 下注册表项的完整名

/v       所选项之下要添加的值名

/ve      为注册表项添加空白值名<无名称>

/t       RegKey 数据类型
           [ REG_SZ    | REG_MULTI_SZ | REG_DWORD_BIG_ENDIAN    |
             REG_DWORD | REG_BINARY    | REG_DWORD_LITTLE_ENDIAN |
             REG_NONE | REG_EXPAND_SZ ]
           如果忽略,则采用 REG_SZ

/s       指定一个在 REG_MULTI_SZ 数据字符串中
           用作分隔符的字符
           如果忽略,则将 "\0" 用作分隔符

/d       要分配给添加的注册表 ValueName 的数据

/f       不用提示就强行改写现有注册表项

例如:

REG ADD \\ABC\HKLM\Software\MyCo
    添加远程机器 ABC 上的一个注册表项 HKLM\Software\MyCo

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
    添加一个值(名称: Data,类型: REG_BINARY,数据: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail
    添加一个值(名称: MRU,类型: REG_MUTLI_SZ,数据: fax\0mail\0\0)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%
    添加一个值(名称: Path,类型: REG_EXPAND_SZ,数据: %systemroot%)
    注意: 在扩充字符串中使用双百分比符号( %% )

添加系统环境变量visual 值为vim, 不过加了之后在命令行用set 还是看不到,需要注销一下或者重启动explorer进程。
reg add "hklm\system\currentcontrolset\control\session manager\environment" /v visual /t REG_SZ /d vim

导出环境变量到env.reg
reg export "hklm\system\currentcontrolset\control\session manager\environment" env.reg

显示注册表系统环境变量:
reg query "hklm\system\currentcontrolset\control\session manager\environment"

 

使用VBS

 

dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
wsh.Environment("system").Item("<变量名>")="<值>"

或使用使用REG

set regpath=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
::系统环境变量
::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
::用户环境变量
::HKEY_CURRENT_USER\Environment
reg add "%regpath%" /v "<name>" /d "<data>"

将上面的<>内容替成你需要定义的名称和值就可以了.

 

 

来源:www.phpvim.net/windows/change-system-environment-variables-with-registry-for-windows-xp.html
大部分情况下我们都是通过Windows自带的环境变量编辑器来修改系统环境变量,也可以通过Windows系统提供的path,set两个命令临时修改。

使用系统编辑器修改环境变量最终会反映到注册表中保存,我们知道环境变量分为两种,用户变量,以及系统变量,其存储的位置分别位于:

系统变量:
[HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment]
[HKLM\SYSTEM\ControlSet002\Control\Session Manager\Environment]
[HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]

用户变量:
[HKCU\Environment]

其中HKLM = HKEY_LOCAL_MACHINE,HKCU = HKEY_CURRENT_USER

ControlSet001/ControlSet002/CurrentControlSet保存用于系统启动的重要配置信息,其中CurrentControlSet指向ControlSet001,两者互相同步,每次针对两者中任意一个分支的修改都会立即复制到另外一个分支相对应的键值中。

当系统启动时,会使用其中一个分支的信息以尝试启动系统,这个就是ControlSet001,如果启动成功,那么ControlSet001的信息会复制到ControlSet002中。如果启动失败,那么就不会发生这个复制过程。

当系统因某些原因无法启动时,我们通常会使用“Using the Last Known Good Configuration”来尝试启动系统,也就是“最后一次正确的配置”(启动时按住F8),这时系统使用的就是ControlSet002分支的配置信息。

Category: windows | Tags: | Read Count: 834
meidir said:
Sun, 09 Oct 2022 22:29:37 +0800

Thanks so much pertaining to giving me an update on this subject on your website. Please understand that if a completely new post becomes available or in case any improvements occur on the current submission, I would be interested in reading more and knowing how to make good using of those strategies you talk about. Thanks for your time and consideration of others by making this web site available. futbol en vivo

 

====================

 

Valuable info. Lucky me I found your site by accident, and I’m shocked why this accident did not happened earlier! I bookmarked it. MaJu Studios

meidir said:
Tue, 18 Oct 2022 18:12:25 +0800

i am addicted to computer games that is why i bought a gamecube for me and my brother,, Commercial Mold remediation spokane

 

===============

 

I’ve viewed some different blog posts with regards to this topic, and I must state that yours shows the most insight. Thanks a lot for expressing your opinions with everyone here. commercial storm damage repair spokane

 

================

 

Your blog is amazing dude. i love to visit it everyday. very nice layout and content ,   commercial fire damage

 

=================

 

I Just stopped by to say your article is great. The clarity in your post is simply spectacular and i can assume you’re an expert on this subject. Fine with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the enjoyable work. commerical water damage

 

====================

 

I was passing around and come across your site. It is wonderful. I mean as a content and design. I added you to my list and decided to spent the rest of the weekend browsing. Well done! Mold remediation spokane

 

=====================

 

Somebody necessarily help to make seriously articles I would state. That is the first time I frequented your website page and to this point? I amazed with the research you made to create this actual submit incredible. Great job! storm restoration spokane

 

======================

 

I do not even know how I ended up here, but I thought this post was great. I don’t know who you are but definitely you’re going to a famous blogger if you are not already Cheers! water damage restoration spokane

 

=======================

 

We still cannot quite believe that I should often be a kind of checking important points seen on your webblog. Our family and i also are sincerely thankful with regards to your generosity too as for giving me possibility pursue our chosen profession path. Wanted you important information I purchased within your web-site. commercial damage restoration

 

=======================

 

This web page is really a walk-through for all of the information you wished about this and didn’t know who to ask. Glimpse here, and you’ll definitely discover it. fire damage restoration in spokane

 

========================

 

Pretty nice post, thanks for the awesome article. I’m having troubles subscribing to your blogs feed. Thought I’d let you know spokane disaster repair

 

========================

 

it is always easy to find good ski resorts online, but most of them are expensive but they are great anyway` Restoration Spokane

 

========================

 

I have been in the same situation before. It’s not as easy an answer as you think it is, it is something that you will need to think through for yourself over a period of time. restoration companies Spokane wa

meidir said:
Wed, 19 Oct 2022 00:15:52 +0800

It is actually a nice and helpful piece of information. I am happy that you just shared this useful information with us. Please keep us up to date like this. Thanks for sharing. rentacarkosovo How To Calculate Air Freight

meidir said:
Sat, 22 Oct 2022 23:56:26 +0800

This is really interesting, You’re a remarkably professional article writer. I have enrolled with your feed and furthermore , count on enjoying the really great write-ups. And additionally, I’ve got shared your webpage throughout our myspace. <a href="https://rhad.agency/psg/">PSG Grant Digital Marketing</a>

meidir said:
Sat, 22 Oct 2022 23:57:14 +0800

Oh my goodness! a wonderful post dude. Thanks a ton Nevertheless We’re experiencing problem with ur rss . Don’t know why Unable to subscribe to it. Is there any person finding identical rss issue? Anybody who knows kindly respond. Thnkx PSG Grant Digital Marketing

meidir said:
Mon, 24 Oct 2022 16:41:01 +0800

I am often to blogging and i truly appreciate your content. The write-up has actually peaks my interest. I am going to bookmark your website and maintain checking for new data. bolsas ecologicas

meidir said:
Tue, 25 Oct 2022 17:41:53 +0800

You got a very wonderful website, Gladiola I noticed it through yahoo. defi yap

meidir said:
Wed, 08 Feb 2023 21:52:09 +0800

I am curious to find out what blog system you are utilizing? I’m having some small security issues with my latest blog and I would like to find something more secure. Do you have any recommendations? SaaS Law Firm


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com