如何使用REG_EXPAND_SZ从命令行? [英] How to use REG_EXPAND_SZ from the commandline?

查看:1234
本文介绍了如何使用REG_EXPAND_SZ从命令行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到有关修改Windows注册表,特别是在REG ADD命令在Windows命令行文档(WIN + F1)命令。

I was reading the Windows Commandline Documentation (Win+F1) about the commands that modify the Windows registry, particularly the the "reg add" command.

reg add HKCU\testfolder /t REG_EXPAND_SZ /v Stokrotka /d "%systemroot%\system32"

现在,我不知道这是如何设计的工作。
当我调用上面的命令中,变量的%systemroot%被扩展到 C:\\ WINDOWS 。我试过下面不使变量扩大,但没有办法,我可能会迫使它不会:

Now, I don't know how this was designed to work. When I invoke the command above, the variable %systemroot% gets expanded to C:\Windows. I've tried the following not to make the variable to expand, but there is no way I could force it not to:


  • 逃避``%%的用`%,^,\\' - 如果我周围使用双引号甚至不工作
  • 使用单引号''围绕整个/ D弦
  • 使用`SETLOCAL setdelayedexpansion`?某物像:
  • escaping the `%%`'s with an `%, ^, \` - doesn't work even if I use double quotes around
  • using the single quotes '' around the whole /d string
  • use `setlocal setdelayedexpansion`? sth like:

#(SETLOCAL enabledelayedexpansion)及和放大器; (REG ADD HKCU \\ testfolder /吨REG_EXPAND_SZ / V Stokrotka / Dsystemroot \\ System32中!)及和放大器; (SETLOCAL disabledelayedexpansion)

变量数据(/ D)领域或者是像 ^%SYSTEMROOT ^%或者像!SYSTEMROOT!或只是扩展到C:\\ WINDOWS。
我大概可以使用.reg文件来完成我的任务,但我根本就不想去做。结果
我想,也许有,我用它来显示变量的内容有点毛病程序(注册表编辑器/ REGEDT32 /注册查询(命令行)),但是经过检查这可能是不是这样的。结果,
有任何想法吗?我主要感兴趣的变量值应该怎么看起来像在注册表编辑器窗口,它应该是这样的:的%SystemRoot%\\ SYSTEM32 C:\\ WINDOWS \\ SYSTEM32来得到妥善的其他程序扩展。
问候。

The variable 'data' (/d) field is either like ^%systemroot^% or like !systemroot! or just expands to C:\windows . I could probably use the .reg file to accomplish my task, but I simply don't want to do it.
I thought that maybe there is something wrong with the program that I use to display the variable contents (regedit / regedt32 / reg query (commandline)), but after checking this is probably not the case.
Any ideas? I'm mainly interested how the variable value should look like in the regedit window, should it be like :"%systemroot%\system32" or "C:\windows\system32" to be properly expanded by other programs. Regards.

推荐答案

在命令行,这为我工作:

From a command line, this worked for me:

reg add HKCU\testfolder /t REG_EXPAND_SZ /v Stokrotka /d ^%systemroot^%\system32

这篇关于如何使用REG_EXPAND_SZ从命令行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆