Why doesn't this work - psexec

Why doesn't this work? I want to copy the file to the remote machine and run it.
psexec \\epo-test -c C:\temp\Avmr64.msi /Silent
Heres the error I get
PsExec could not start Avmr64.msi on epo-test:
The system cannot find the file specified.
I am trying to copy Avmr64.msi over to epo-test and run a silent install but I get this
PsExec could not start Avmr64.msi on epo-test:
The system cannot find the file specified.
Any help would be great.

For those that are interested heres the answer
psexec -u domain\username \\system -s -i -d msiexec.exe /i "\\share\folder\msifile" /qb

I think what you're trying to run here is "/Silent". Try instead:
psexec \\epo-test -c C:\temp\Avmr64.msi "C:\temp\Avmr64.msi /Silent"
or something in that fashion.

Try the below ( untested ):
psexec \\epo-test -c C:\temp\Avmr64.msi "msiexec /i /passive Avmr64.msi"
http://forum.sysinternals.com/topic2542.html

Related

powershell cannot run a command from "Run as" box

I have a one liner that I run from the windows run command :
"C:\Program Files (x86)\casper\PuTTY\putty.exe" -ssh "192.168.1.2" -l casper -pw "<password>" -m \\PROD.MSAD.casp.NET\UserData\CASPER\Home\Documents\pbauth_list.txt -t
It works great.
However I tried copying the one liner to a .ps1 file like this:
start "C:\Program Files (x86)\casper\PuTTY\putty.exe" -ssh "192.168.1.2" -l casper -pw "<password>" -m \\PROD.MSAD.casp.NET\UserData\CASPER\Home\Documents\pbauth_list.txt -t
Running it from powershell and I get his error
The system cannot find the file -ssh
Saved this as a .bat and tried to open in thorough powershell
I get a message box
Windows cannot find '-ssh'. Make sure you typed the name correctly, and then try again
I have tried all types of permutations with escaping the quotes, quoting the whole line. Can't get it to work as a saved command but it works great from the run as box. The same command worked fine from the run dialog box.
Instead of start, you should be using & "C:\Program Files (x86)\casper\PuTTY\putty.exe" <rest of args>
I would run the command like this.
Start-Process "C:\Program Files (x86)\casper\PuTTY\putty.exe" -Argumentlist "-ssh", "192.168.1.2", "-l", "casper", "-pw", "<password>", "-m", "\\PROD.MSAD.casp.NET\UserData\CASPER\Home\Documents\pbauth_list.txt", "-t"
This to make sure that arguments are sent to the putty command and not to the start command which is your issue.

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 cannot kill cmd.exe & psexec.exe after execute

i had used a batch cmd (xxx.bat) to execute a psexec function as follows:
C:\psexec.exe \192.168.xxx.xx -u server1\admin -p password C:\xxx.bat
the above batch file can run successfully to remote execute file.
but i found that there are many cmd.exe and psexec.exe process in task manager, that the batch file cannot kill process after execute.
do you know how to kill cmd.exe and psexec.exe process after execute ?
thanks
Joe
I'm sure there's a better way, but personally, I do this using pskill, e.g.:
pskill.exe \\\\192.168.x.x -u user -p pass -t <imagename>
You can find the name of the executable that you want to kill using the pslist command, also in the pstools toolset.

PsExec run remote batch file in visible mode

I am trying to execute following command
psexec \\x.x.x.x -d -c -f cmd.exe /c d:\test\hello.bat
It runs fine and gives output
cmd.exe started on x.x.x.x with process ID 106084.
But when I login on x.x.x.x I can find the process ID but no visible batch file is launched. It runs in background.
Batch file
echo "Hello"
pause
Please tell me how to see the command window launched on x.x.x.x
Thanks in advance
I think you can look at the Session Id for your current user and pass it as parameter with -i For example:
PsExec.exe -s -d -i 2 c:\temp\MyServer MyConsoleApp.exe
To look at the current Session Id you can run query session
Sometimes the Session Id is 2 for the active user you want to start process for, so try looking for your correct Session Id and use it with -i parameter.
Try one of those:
psexec \\server -u xxx-p xxxx /accepteula -i 1 -d cmd.exe /K "cd d:\test && call hello.bat"
psexec \\server -u xxx -p xxxx /accepteula -i 1 -d d:\test\hello.bat
Alex K. is correct. Specifically, remove the "-d", which tells PsExec "Don't wait for process to terminate (non-interactive)". In fact, if you run the sample batch file above, which includes "pause", the cmd process will continue to run on the remote host (invisible to the remote host's GUI, since it's done via PSExec) until you kill that process.
PsExec.exe -s -i 2 C:\path_to_exe.exe
This need to check with the session ID variable (-s & -i)

How to check remote server time via psexec

I tried command like below. But can't see server time.
psexec \\SERVER_NAME -i -u USERNAME -p PWD "C:\WINDOWS\system32\cmd.exe /c time /t"
Or is there any alternative? Thanks.
net time \\SERVER_NAME
Ps. This question really belongs at ServerFault.
I have about 100 servers in my company. Once i had to check system time on all servers.
The solution was:
psexec -d -i cmd /c nettime.bat
content of nettime.bat file :
#echo off
net time \\server01 >>c:\1.txt
net time \\server02 >>c:\1.txt
net time \\server03 >>c:\1.txt