批处理,在引号中添加引号可停止reg的工作 [英] Batch, adding quotes to argument stops reg from working

查看:60
本文介绍了批处理,在引号中添加引号可停止reg的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图制作一个在打开txt文件时运行的批处理文件.

So i tried to make a batch file that runs when a txt file is opened.

reg add HKCR\txtfile\shell\open\command /ve /t REG_EXPAND_SZ /d %0 /f

到目前为止,一切都很好.但是,当我打开文本文档时,由于%0中的空格而导致错误.

So far so good. But when i open the text document theres an error due to spaces in %0.

reg add HKCR\txtfile\shell\open\command /ve /t REG_EXPAND_SZ /d "%0" /f

这不会给我一个错误,但是注册表值不会改变.

This doesnt give me an error, but the registry value doesnt change.

reg add HKCR\txtfile\shell\open\command /ve /t REG_EXPAND_SZ /d ^"%0^" /f

同一件事.那我的问题是什么?

Same thing. So whats my problem here?

推荐答案

在这种情况下,转义字符(完全缺乏一致性,我知道)是反斜杠:

The escape character in this case, (complete lack of consistency, I know), is the back slash:

Reg Add "HKCR\txtfile\shell\open\command" /VE /D \"%~0\" /F >Nul

这篇关于批处理,在引号中添加引号可停止reg的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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