如何使用bat文件创建注册表项

发布于 2024-09-30 06:13:47 字数 111 浏览 0 评论 0 原文

需要使用bat文件创建注册表项。我可以使用命令提示符或bat文件创建注册表项吗?

这背后的主要目的是,我想使用bat文件创建环境变量。

Need to Create a Registry Key using bat file.Can I create Reg Key using Command prompt or a bat file.

The main purpose behind this , I want to create envoirment variable using bat file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

所谓喜欢 2024-10-07 06:13:47

您可以使用 Windows 内置命令行工具,regedit.exereg.exe,请参阅:

You can use the Windows built-in command line tools, either regedit.exe or reg.exe, see:

冷默言语 2024-10-07 06:13:47

是的,您可以使用批处理文件创建注册表项,

这里是一个示例:

使用 .bat 文件禁用任务管理器:

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /f /v DisableTaskMgr /t REG_DWORD /d 1

启用任务管理器:

reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /f

您可以通过输入 reg/? 来获取帮助?在命令提示符下的各种选项。

享受.........

Yes u can create Registry Key using Batch file

here is an example:

for disabling task manager using .bat file:

reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /f /v DisableTaskMgr /t REG_DWORD /d 1

for enabling task manager:

reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableTaskMgr /f

You can take Help by entering reg/? in command prompt for various options.

Enjoy.........

萌酱 2024-10-07 06:13:47

设置变量=字符串

SET variable=string

怪异←思 2024-10-07 06:13:47

如果您想创建一个持久环境变量(即不仅适用于当前会话的变量),您可以使用setx。如果有程序可以为您完成此操作,则无需直接修改注册表:

SetX has three ways of working:

Syntax 1:
    SETX [/S system [/U [domain\]user [/P [password]]]] var value [/M]

Syntax 2:
    SETX [/S system [/U [domain\]user [/P [password]]]] var /K regpath [/M]

Syntax 3:
    SETX [/S system [/U [domain\]user [/P [password]]]]
         /F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]

Description:
    Creates or modifies environment variables in the user or system
    environment. Can set variables based on arguments, regkeys or
    file input.

If you want to create a persistent environment variable (i.e. one that not only applies to the current session) you can use setx. No need to mess around with the registry directly if there is a program to do it for you:

SetX has three ways of working:

Syntax 1:
    SETX [/S system [/U [domain\]user [/P [password]]]] var value [/M]

Syntax 2:
    SETX [/S system [/U [domain\]user [/P [password]]]] var /K regpath [/M]

Syntax 3:
    SETX [/S system [/U [domain\]user [/P [password]]]]
         /F file {var {/A x,y | /R x,y string}[/M] | /X} [/D delimiters]

Description:
    Creates or modifies environment variables in the user or system
    environment. Can set variables based on arguments, regkeys or
    file input.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文