@ECHO OFF
:: Ask for Credentials
IF NOT EXIST containers/api (
set /p login="Enter your git username: "
powershell -Command $pword = read-host "Enter password" -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt & set /p password=<.tmp.txt & del .tmp.txt
)
the code above doesn't work with the error message:
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) was unexpected at this time.
The same code without IF, works just fine
@ECHO OFF
:: Ask for Credentials
set /p login="Enter your git username: "
powershell -Command $pword = read-host "Enter password" -AsSecureString ; $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword) ; [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) > .tmp.txt & set /p password=<.tmp.txt & del .tmp.txt
what I'm doing wrong?
;in the statement is terminating the powershell command in theifcase or something like that. If you quote the entire powershell command string does it work?)atSecureStringToBSTR($pword)prematurely closes theIFparenthesis. You'll need to do a bit of string quoting malarky to get this to work. Don't forget you can use single'quotes in PowerShell too.