I have the following for loop inside batch file:
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
)
And I always get the following error: [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" was unexpected at this time.
When I run the command outside the for loop, it works.
What is wrong?
set
and one for the-Command
and they're probably canceling each other. – Seth Sep 20 '16 at 10:01