psexec How to run exe on remote computer - psexec

I'm trying to run a program on a remote computer, but can't find the file. Whats wrong?
C:\temp\PSTools>psexec \\nb_IT10 -u godr\jak -p pimpam1+ c:\Program Files (x86)\Notepad++\notepad++.exe
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
PsExec could not start c:\Program on nb_IT10:
The system cannot find the file specified.

You can do this with the following syntax, noting that the program you are trying to run should exist on the remote computer already with this syntax. If you only have Notepad++.exe installed locally, you'd have to use the "-c" parameter of psexec to copy that program to the server to run.
psexec \\nb_IT10 -u godr\jak -p pimpam1+ "C:\Program Files (x86)\Notepad++\notepad++.exe"
Full documentation for PSExec is available at the following link with examples PSExec - Windows Sysinternals

Related

Input to psexec command

I am trying to run a batch file which is placed in a remote windows server from my local system.
For that I am using psexec command as shown: psexec \\ip address -u user\username -p password cmd /c "path to batch file". This is executing same way as it executes on remote windows server. but at some point we have to press Q on the command prompt to get to next line on the batch file.
this is how it looks:
on Remote system
But I am unable to press Q on my local psexec command prompt, this is how it looks:
on my local system
is there a way to take key inputs for psexec command?
Thanks in advance.
I tried providing -accepteula option and also pipe it with powershell and try running it.
But no luck on that.

psexec command runs locally instead of remotely

I am trying to use psexec to download an installer and then execute the installer on a remote VM, but the command passed to psexec runs locally instead of remotely
When I run
PS > psexec \\RemoteVmName -u VmAdminUsername -p VmAdminPassword powershell (New-Object System.Net.WebClient).DownloadFile("http://ServerAddress:8080/MyInstaller.msi", "C:/installer.msi")
Expected Behavior
File gets downloaded to C:/installer.msi on the remote machine
Observed Behavior
File gets downloaded to C:/installer.msi on the local machine, the machine where psexec is being called from
Running psexec into a powershell prompt and then calling the download file method gets the desired behavior, but I need this to run without manual steps.
Works Manually
PS > psexec \\RemoteVmName -u VmAdminUsername -p VmAdminPassword powershell
PS > (New-Object System.Net.WebClient).DownloadFile("http://ServerAddress:8080/MyInstaller.msi", "C:/installer.msi")
That gets the installer on the remote machine but requires human input. I need to do the same without human input.
Using the -i and -h flags are not helping.

copy with PSEXEC hangs some times in batch execution

im copying multiple files to server Machine using PSEXEC,Calling Psexec is through perl file
my $exit_code5 = system("cmd /c c:\\PsExec.exe \\\\$host_name -u $user_name -p \ $pwd cmd /c xcopy \"\\\\$client\\c\$\\sif folder\\$val\" \"c:\\sif folder\\\" /O /X /E /H /K /Y /q");
sleep(20);
}
if($exit_code5!=0)
{
}
This command is working fine , but sometimes in batch executions it randomly fails
-----Copying files to BackUpFolder SiebsvrBackUp created in C Drive-----
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com
and will be in hang state... Is there any consistent way to perform multiple file copy using PSEXEC, Have tried COPY Command to, but no use
Try adding -d in your command since it doesn't wait for the process to terminate
https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

Psexec is not running an EXE program remotely

Check everywhere for a reason but nothing I found matches my specific problem. I have a program in C:\somefoldername\anothersubdirectory\andanother\ of the remote pc that I try to run using PSEXEC but it does not take. PSEXEC just does not want to run anything for me. Now if I run a ping or tasklist via psexec, it works, though obviously this is in PATH.
So I am putting in:
PSEXEC \\pcname C:\somefoldername\anothersubdirectory\andanother\program.exe
and nothing happens.
I even wrote a batch script that I tried running in two different ways.
Script is just:
#ECHO OFF
C:\somefoldername\anothersubdirectory\andanother\program.exe
EXIT
and I had it copied to the remote pc's main directory (maybe I need to put it in a folder) and then I tried running C:\batch.bat using:
PSEXEC \\pcname C:\batch.bat
I also tries running:
PSEXEC \\pcname -c \\servername\batch.bat
so it copies it over to PATH.
Neither worked.
Does any program I try to run via PSEXEC have to be in the remote pc's path?
I do have to admit that I have not done running an EXE remotely, but I have written lengthier scripts using psexec that use batch file on a server without any hiccups.
What is weird to is that the program I run has parameters and I task that runs through it, so I first taskkill it remotely, then I PSEXEC the SAME EXACT EXE as:
psexec \\pcname C:\...\program.exe -a -few -parameters ODBC
and that works. When I try to open just program.exe on its own, nope doesn't take.
I also did try psexecing iexplore.exe and that didn't work either.
So gotta use the -i option. In addition to that, gotta use -p + -u or -s to load system hardware dependent gui. This is why large portions of the gui was missing, or I assume why.
Can you please try this format
psexec \\machineName -u username -p password /accepteula -h cmd /c
C://somefoldername//anothersubdirectory//andanother//program.exe >>log.txt
More Clearly
Download the PSEXEC tool zip file in your user machine and unzip it.
Open command prompt and go to the psexec path.
In my machine it is: D:\PsTools
Run following command line
Syntax:
D:\PsTools> psexec \\ip_address -u username -p Password cmd /c executablename arguments >> test.log

PsExec on two XP machines says "Access Denied"

I have two XP machines and I have the following situation.
I am running psexec from comp1
comp2 does not have any password
My bat file command
psexec -i -d -c \\comp2 c:\xyz.exe
The error message I get is
Couldn't access comp2: Access Denied
I also added new user 'test' with password 'abcd' on comp2 and logged in then from comp1. I gave command
psexec -i -d -c \\comp2 -u test -p abcd c:\xyz.exe
but the error remains the same. Please help.
Are you using XP Home by chance? According to the Sysinternals Forums here, one of requirements for psexec is check the target machine to make sure it's not running Windows XP Home because it lacks the network functionality required by (most) PSTools commands. The issue with XP Home was also investigated in detail in this thread from the same forum.