Powershell command-line with Autologon.exe

放肆的年华 提交于 2019-12-12 10:16:19

问题


Has anyone made the 'Autologon.exe for Windows v3.10' work with PowerShell v5.1?

Execution 1:

As administrator the following is run:

.\Autologon.exe -n guest10 -d test.com -p Password1 -accepteula yes

Error 1:


Execution 2:

As administrator in powershell the following is run:

.\Autologon.exe guest10 test.com Password1

Error2: Nothing happens


Execution 3:

As administrator in powershell the following is run:

$obj=.\Autologon.exe
        $name ="guest10"
        $domain="test"
        $pass="Password1"
        & $obj $name $domain $pass

Error3:

The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.


回答1:


I generally use Start-Process with the ArgumentList parameter to run programs with arguments:

$autologon = "C:\folder\Autologon.exe"
$username = "guest10"
$domain = "domain"
$password = "Password1"

Start-Process $autologon -ArgumentList $username,$domain,$password

Or you can put them directly into the command:

Start-Process "C:\folder\Autologon.exe" -ArgumentList "guest10","domain","Password1"



回答2:


This worked for me:

Start-Process -FilePath $exePath -ArgumentList "/accepteula", $user, $domain, $password -Wait

It's very picky about quote placement.



来源:https://stackoverflow.com/questions/42740419/powershell-command-line-with-autologon-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!