FOR循环中的Windows批量powershell命令不起作用
我在批处理文件中有以下循环: for /l %%x in (1, 1, %k%) do ( set "psCommand=powershell -Command "$pword = read-host 'Enter Password2' -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p ) 我总是得到以下错误: [System.Runtime.InteropServices.Marshal] :: PtrToStringAuto($ BSTR)“”此时出乎意料。 当我在for循环外运行命令时,它可以工作。 怎么了?