Psexec, issue with the input RRS feed

  • Question

  • Hello everybody 
    So, I have two computers: pc1 and pc2.

    On pc2 i made a batch script that creates users, it is working.
    Here is the code :
    @echo off

    set /p "login= enter the login: "

    net user "%login%" /add 

    The idea that i have, is to run this script from another pc (pc1) remotely by using psexec.
    i launch the following command from pc1 :

    psexec \\pc2 -u Administrator -p password cmd 

    then i go to the c drive of the remote machine, and i run the script ,the issue is that the user is add but only with the first character..for exemple let's say i want to add the user "test", after executing the script this user will be add as "t" , i don't know why it keeps only the first letter, any ideas please? 
    Thank you 

    Sunday, September 16, 2018 6:28 PM

All replies

  • Hi,

    Here's a forum post where they're talking about this specific issue:

    Best regards,

    Blog: LinkedIn:

    Sunday, September 16, 2018 7:46 PM
  • Hello Leon thank you for you answering me It seems that’s it’s an issue with psexec, I don’t know if i have to modify my script or try paexec, have you ever installed paexec ?
    Sunday, September 16, 2018 10:26 PM
  • I haven't used Paexec before, just tested it in my lab environment and had some permission issues when I tried performing the exact similar steps as with PSExec.

    What worked for me was to run the process with the system account, as follows:

    paexec.exe \\DestHosname -u Username -p Password -s cmd

    The -s switch:         Run the process in the System account.

    My Script.bat file:

    @echo off
    set /p "login= enter the login: "
    net user /add "%login%"  "P4ssw0rd"

    Blog: LinkedIn:

    Monday, September 17, 2018 7:08 AM
  • Hello Leon Thank you again for answering me So it seems to work with paexec., the only that I have is I don’t know how to install it? I download paexec, it’s an executable application, not filles such as psexec that we can copy and past . How did you do the installation ?
    Monday, September 17, 2018 8:13 AM
  • It is an executable file just like PSExec.exe, just extract it from the archive.

    Blog: LinkedIn:

    Monday, September 17, 2018 9:27 AM
  • hello Leon I extracted paexec as suggested, it gave me 5 files (.data,.rdata,.reloc,.text,Certificate) and a directory (.rsrc) I copied this files in the following path C:\windows\system32 , but when I typed paexec in cmd it gave me : unrecognized command, I copied then the paexec.exe to the same path and it worked. The issue is that when I type the following command it keeps giving me the paexec menu , like if I type only paexec : Here is the coammand : paexec \\servername -u Administrator -p password -s cmd , I also tried with paexec.exe When I replace paexec with psexec,it’s working I connect to the remote machine... II don’t know where i failed, any idea ? Sorry for bothering you with this

    • Edited by Krotzmann Monday, September 17, 2018 3:33 PM
    Monday, September 17, 2018 12:52 PM
  • I just downloaded the paexec.exe from here:

    Copy this file to C:\Windows\System32\ and you should be good to go!

    Blog: LinkedIn:

    Monday, September 17, 2018 6:01 PM
  • Hello leon I did all the steps, when I type the following command PAExec \\remotemachine -u Administrator -p password -s cmd.exe I get this error: Failed to start service on x.x.x.x the service has not been started. PAExec returning exitr code -6
    Tuesday, September 18, 2018 10:30 AM
  • It seems to have issues copying the exe / starting the service from C:\Windows\System32.

    As you can see above, I ran PAExec from C:\Temp.

    I tried running from C:\Windows\System32 and I got the same errors as you've got and I couldn't get it to work, but from another location I got it working just fine.

    Blog: LinkedIn:

    Tuesday, September 18, 2018 11:16 AM
  • Hello I tired to start it from temp but no luck, same issue. Any idea about how to run my add user script with ps exec ? An alternative to add all the user name not only the first letter?
    Tuesday, September 18, 2018 1:39 PM
  • With what account are you running this?

    1) Download the PAExec.exe to C:\Temp.

    2) Copy your Script.bat to another server (for example \\Server2\C$\Temp\)

    3) Open a Command Prompt (Admin).

    4) Head to the C:\Temp folder.

    5) Run the following command:

    paexec.exe \\Server2 -u Username -p Password -s cmd

    Script.bat file:

    @echo off
    set /p "login= enter the login: "
    net user /add "%login%"  "P4ssw0rd"

    I run this with a Domain Admin account, make sure that you have enough permissions on the destination server.

    Blog: LinkedIn:

    Tuesday, September 18, 2018 1:45 PM
  • I start the script from an admin account ... I don’t think it’ have to do with it because psexec is working fine.. this thing is getting more crazy lol, I have installed PAExec on vmware on my compute, on two machines. The first one is not working , it gives me error 6 , failed to start paexec (exactly the same error as in the office), and the second one is working fine... both of the vms were installed with same image... I don’t know what’s wrong ... something is missed
    • Edited by Krotzmann Tuesday, September 18, 2018 6:35 PM
    Tuesday, September 18, 2018 6:32 PM
  • I tried to start the command from temp , same issue
    Tuesday, September 18, 2018 6:33 PM
  • Is there a reason why you're not using PowerShell?

    You can use the NET cmdlets within PowerShell as well.


    Blog: LinkedIn:

    Tuesday, September 18, 2018 7:28 PM
  • Hello I tried to use powershell but i still have the same issue with paexec, is there an alternative to execute a script remotely ? Thank you a lot for your anawers
    • Edited by Krotzmann Wednesday, September 19, 2018 7:24 AM
    Wednesday, September 19, 2018 7:22 AM
  • What's the problem with PowerShell?

    I'm afraid these are the options out there, you could still try to use PSExec and try to come up with something else than the /set p  

    What is it you want to achieve here by doing this?

    Blog: LinkedIn:

    Wednesday, September 19, 2018 9:31 AM
  • Hello Leon I made up a powershell script, and wanted to launch it from psexec : Here is the script : $Name = Read-Host “enter the login” Net user / add $Name “password” It is working, I even launched the script from local machine cmd and it’s working via the following command : powershell -command ./script.ps1 , it is working I tried to do the same operation from my pc with the following command: psexec \\remotemachine -u Administrator -p password Then I go to C drive and launch the powershell script but it doesn’t start. If you have time please try it and tell me if it is working .
    • Edited by Krotzmann Wednesday, September 19, 2018 5:27 PM
    Wednesday, September 19, 2018 5:26 PM
  •  I don't want to detract from the great contributions that everybody else has made on this thread except to say that I've added this problem to the PSExec backlog. Will update when we have a fix for it.

    Thanks for taking the time to report the issue and for the links

    MarkC (MSFT)

    Wednesday, September 19, 2018 7:39 PM
  • @Krotzmann: I couldn't get it working from my quick tests with both PSExec & PowerShell.

    Was there a reason to not use just PowerShell?

    PowerShell example:

    @MarkC Thanks!

    Blog: LinkedIn:

    Wednesday, September 19, 2018 8:59 PM
  • @MarkC, thank you for supporting, please give us a feedback if the issue is fixed. @leon : thank you again for the time that you are giving to my thread, thank you very much. I will explain a little bit my situation, so I have two pcs, one is my server and the other one is a computer that i want to add users to it by a script. But i want to do it from my server, i want to execute the add user script from my server save time. Can I do this with just powershell ? The last script that you showed me, it add users only from the local machine am iI wrong ? Thank you again for helping

    • Edited by Krotzmann Thursday, September 20, 2018 3:40 PM
    Thursday, September 20, 2018 3:38 PM
  • Okay, this can be done with PowerShell yes, and this script only adds users locally.

    Do you need to add users to the domain or just locally?

    Blog: LinkedIn:

    Thursday, September 20, 2018 3:40 PM
  • Then this script should work just fine for this cause!

    Blog: LinkedIn:

    Thursday, September 20, 2018 5:26 PM
  • But how can I execut it remotely ? Is there any command for that in powershell ? How can I execut this powershell script from my server, for adding users in the other pc ?
    Thursday, September 20, 2018 6:18 PM
  • In my latest PowerShell script I am doing exactly this :-) Have you tried it?

    Blog: LinkedIn:

    Thursday, September 20, 2018 6:30 PM
  • So if I understand you just put the username and password (Administrator) for the remote machine on the script, you specify the name of the machine, and the path for the script, and you execute the script ? That’s it ? It looks pretty simple and easy, better than psexec I will give it a try tomorrow in the office and will give you a feedback. Thanks again dear leon
    Thursday, September 20, 2018 6:41 PM
  • Yes that's right, I used a domain account that has local administrator permissions on the remote client.

    Blog: LinkedIn:

    Thursday, September 20, 2018 6:43 PM
  • Do I have to enable some feature of option to do this remote thing with powershell ? Knowing that i never tried it, and I’m not so familiar with powershell
    Thursday, September 20, 2018 6:48 PM
  • It should work just like that unless you have any restriction policies enabled.

    Blog: LinkedIn:

    Thursday, September 20, 2018 6:51 PM
  • Okay , i will give it a try tomorrow, hopefully it will work , thank you🙏🙏🙏
    Thursday, September 20, 2018 8:22 PM
  • Hello Leon
    This is the script that i'am using now, but i still keep getting an error message (see below)
    For the Script : Administrator / password , are the admin and pass of the remote machine

    $username ='Administrator'
    $Password = 'Password'
    $pass = ConvertTo-SecureString -AsPlainText $Password -Force

    $SecureString = $pass
    # Users you password securly
    $MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$SecureString

    Invoke-Command -ComputerName KSMACIM07 -Credential $MySecureCreds -FilePath C:\Windows\Temp\Script.ps1

    KSMACIM07 is the name of the remote machine , and the path is the location of the script.ps1 (add user) in the remote machine

    the error says that " Cannot find the path C:\Windows\Temp\Script.ps1, because it doesn't exist"
    Any suggstion?

    Friday, September 21, 2018 8:59 AM
  • Copy the Script.ps1 to the destination computer’s ”C:\Temp\” drive and use that as a path instead of ”C:\Windows\Temp\”

    Blog: LinkedIn:

    Friday, September 21, 2018 9:05 AM
  • I don't have C:\Temp in my remote machine (KSMACIM07) , i only have C:\Windows\Temp

    FilePath C:\Windows\Temp\Script.ps1 , is the path of script in the remote machine (not the local one)

    • Edited by Krotzmann Friday, September 21, 2018 10:03 AM
    Friday, September 21, 2018 10:03 AM
  • I would advise you to have the script somewhere else than "C:\Windows\...". I created the "Temp" folder under C:\ manually. You can also create one, doesn't have to be named "Temp" could be "Scripts" or anything else :-)

    Blog: LinkedIn:

    Friday, September 21, 2018 10:08 AM
  • I tried to launch only this command :

    Invoke-Command -ComputerName Computername -Credential Administrator -Credential Administrator -ScriptBlock {Get-Culture}

    But i had this error

    Connecting to remote Server computername failed with the following error message : winRM cannot process the request. The following error with errorcode 0x80090311 occured while using
    kerberos authentication : there currently no logon servers available to service the logon request.
    possible causes are:
    -The user name or password specified are ivnalid.
    -kerberos is used when no authentication method and no user name are specified
    kerberos accepts domain user names, but not local user names
    the service Principal Name (SPN), but not local user names
    Note that computers in the TrustedHosts list might not be authenticated.

    My remote computer is not part of a domain , i need to create only local users (it's a windows 7 client embedded)

    Any idea?

    Friday, September 21, 2018 2:00 PM
  • I suggest you have a look at the following blog post regarding remote powershell on non-domain computers:

    Blog: LinkedIn:

    Friday, September 21, 2018 2:02 PM
  • Hello Leon

    Still me lol

    i wanted to ask you if there is a way to import a csv or text file that contains users and passwords, and execute it in a script, to add these users in my local machine which is not part of a domain, only a workgroup.

    Any idea?

    Thursday, September 27, 2018 8:49 PM
  • You can do this with PowerShell by using the Import-CSV cmdlet.

    There's an earlier post about using PowerShell Import-CSV with PSExec here.

    Since this is going more in to PowerShell, I suggest you ask in the PowerShell forums below to get the best answer.

    Scripting  >  Windows PowerShell

    Blog: LinkedIn:

    • Proposed as answer by Leon Laude Thursday, October 4, 2018 6:49 AM
    Thursday, September 27, 2018 8:58 PM