2

I'm using a program called psExec to remotely connect to a machine and start an interactive program.
The machine I'm connecting to, does not have a password.

So if I run this:

psExec \\Computer_Name -u User -i -d calc.exe

It prompts me for a password:

Password:  

I just hit enter(since the computer doesn't have a password), and it works.


I don't want to have to hit enter every time, because I am writing a script.
So I tried this:

psExec \\Computer_Name -u User -p -i -d calc.exe

and this:

psExec \\Computer_Name -u User -p"" -i -d calc.exe

and this:

psExec \\Computer_Name -u User -p'' -i -d calc.exe

and this:

psExec \\Computer_Name -u User -p "" -i -d calc.exe

and this:

psExec \\Computer_Name -u User -p '' -i -d calc.exe

but no matter what, specifying the p flag results in a "Wrong Username or Password error."

How can I tell my script to either press enter automatically, or automate psExec to connect automatically without a password?

I'm in PowerShell if that is relevant.

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
  • 1
    Did you try `-p ''` or `-p ""` with a space? – Etan Reisner May 12 '15 at 14:13
  • @EtanReisner Yes. Same problem. Not sure if it is a psExec related issue or something to do with Windows differentiating between no password and a password that's blank. – Trevor Hickey May 12 '15 at 14:21
  • Try creating a text file which just has a carriage return in it. Then pipe it into the command like: psExec \\Computer_Name -U User -i -d calc.exe < carriagereturn.text Note: This probably won't work, as the PS Utils tend to be smart, but it's worth trying. – Mr. Smythe May 12 '15 at 14:26
  • 2
    Have you tried `-p $null` or `-p "''"`? If that doesn't work you could take a look at [this](http://stackoverflow.com/questions/17849522/how-to-perform-keystroke-inside-powershell). It gets a process and presses Enter for you – MonkeyDreamzzz May 12 '15 at 14:52
  • `-p '""'` worked for me. Specifically `psexec.exe \\remotehost -h -accepteula -p '""' -u username -w c:\tmp powershell.exe -windowstyle hidden`. Of course it didnt then give me a prompt I could interact with, but it did log in. – john v kumpf Nov 10 '21 at 01:37

3 Answers3

1

PSEXEC is a program that is offered as a suite of tools from Microsoft. PSEXEC Link

but for security reasons this can cause some issues, you can add a second account to the machine and give it a simple password and run the script against that account, that would be the easiest way, other wise you can most likely accomplish the same task in powershell not using PSEXEC, what is it that you are trying to do and we can try help get something written.

UPDATE:

param (
    [Parameter(Mandatory = $true)]
    $Password
)
psExec \\OAIJCTDU8024272 -u User -p $Password -i -d calc.exe
Luke
  • 647
  • 1
  • 8
  • 22
  • I'm trying to login to a machine on the network, and start an interactive program. I don't have permission to add another account or a password to the machine(by permission, I don't mean windows permissions- I mean employer permissions. Powershell can not run programs interactively as it violates the security model. – Trevor Hickey May 12 '15 at 19:46
  • @TrevorHickey that makes more sense, now I can't fully test the code but I edited my answer above, save that as a powershell script and run that and confirm that it will start with no password Entered – Luke May 12 '15 at 19:57
1

It seems to work if you put a ~ for the password in powershell.

./psexec -i -u domain\gmsa$ -p ~ notepad.exe

My use case was getting it to skip the enter keypress when using psexec to run something as a group managed service account (gMSA).

jhiller
  • 211
  • 2
  • 4
0

Give this a shot when all else fails. It just passes a return.

Write-Host "" | psExec \\Computer_Name -u User -i -d calc.exe
Blake Drumm
  • 137
  • 1
  • 7