I'm trying to configure autologon.exe using the command line (via PsExec). However, the special characters in the password are causing issues.
Given this password: I'vegotspe"cia"char@ters
This command works:
Start-Process 'C:\Autologon.exe' -ArgumentList 'username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'
However since I'm using PsExec the I need to make the call with "/c" so I have the following command.
powershell.exe /c "Start-Process 'C:\Autologon.exe' -ArgumentList 'username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'"
This command doesn't output any errors but it doesn't work either. It works if I don't have the double-quote character. Any idea how I can make this work?
I'm using PyPsexec so once I get the above command working; the call would look like this
c.run_executable("powershell.exe", arguments=''' /c Start-Process 'C:\Autologon.exe' -ArgumentList 'username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula' ''')
UPDATE 1: Just tried the EncodedCommand as @lit suggested but I seem to have the same syntax issue since it needs to be wrapped in quotations.
COMMAND:
[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("Start-Process 'C:\Autologon.exe' -ArgumentList 'username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'"))
OUTPUT:
ine:1 char:140
+ ... ess 'C:\Autologon.exe' -ArgumentList 'username','hostname','"I''vegot ...
+ ~
Missing ')' in method call.
At line:1 char:140
+ ... username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'"))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token 'I''vegotspe\"cia\"char@ters"','/accepteula'"' in expression or statement.
At line:1 char:184
+ ... username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'"))
+ ~
Unexpected token ')' in expression or statement.
At line:1 char:185
+ ... username','hostname','"I''vegotspe\"cia\"char@ters"','/accepteula'"))
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall