[英]When using parenthesis in registry name in Get-ACL command used in subprocess in python gives error
ps_cmdlet = r'Get-Acl -Path "HKLM:\SOFTWARE\{ab}" | Format-List'
p = subprocess.call(['powershell', '-Command', '& {'+ps_cmdlet+'}'],shell=True)
I am getting the following error 我收到以下错误
Get-Acl : Cannot find path 'HKLM:\SOFTWARE\{ab}' because it does not exist.
At line:1 char:4
+ & {Get-Acl -Path "HKLM:\SOFTWARE\{ab}" | Format-List}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-Acl], ItemNotFoundException
+ FullyQualifiedErrorId : GetAcl_PathNotFound_Exception,Microsoft.PowerShell.Commands.GetAclCommand
用反引号将括号转义:
ps_cmdlet = r'Get-Acl -Path "HKLM:\SOFTWARE\`{ab`}" | Format-List'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.