标题: [注册表类] [求助]reg add 命令字数太长如何解决? [打印本页]
作者: lijinan 时间: 2019-10-25 21:35 标题: [求助]reg add 命令字数太长如何解决?
reg query "HKCR\Microsoft.PowerShellScript.1\shell"
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas" /f
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas" /v "HasLUAShield" /f
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas\Command" /f
:: PowerShell.exe "-Command" "if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'"
reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas\Command" /ve /d "PowerShell.exe \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
最后一句应该是字符太长无法执行?
作者: xczxczxcz 时间: 2019-10-26 16:14
绝对不是太长,才多少个字节。试试这个:功能未测试,只是验证加入注册表而已。- reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas\Command" /ve /d "cmd.exe /c & call powershell.exe -command \"if((Get-ExecutionPolicy).toString() -ne 'AllSigned'){Set-ExecutionPolicy -Scope Bypass}\""
复制代码
作者: lijinan 时间: 2019-10-26 21:58
回复 2# xczxczxcz
本意实现右键管理员运行ps1文件;上述reg add执行成功,功能暂时还不满足。
作者: WHY 时间: 2019-10-26 22:54
本帖最后由 WHY 于 2019-10-27 15:48 编辑
数数看,双引号有几个,双引号对(相邻的两个双引号为一对)有几对,&字符在引号对外面还是里面?
如果位于双引号对之外就要转义。
在批处理中%也要转义。
作者: aceamuro 时间: 2019-10-27 08:51
我都是直接导入或用powerun运行.reg文件,执行速度快很多,还不会出错
作者: WHY 时间: 2019-10-27 15:55
本帖最后由 WHY 于 2019-10-28 09:05 编辑
好吧,贴个现成的- reg add "HKCR\Microsoft.PowerShellScript.1\shell\runas\Command" /ve /d "%winDir%\System32\WindowsPowerShell\v1.0\PowerShell.exe -C \"Set-ExecutionPolicy -Scope Process Bypass; ^& '%%1'\"" /f
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |