Run PSEXEC
Posted: 02 Apr 2020 12:35
I would like to run a program on a remote PC.
I'm signed on to PC#1 at 192.168.168.7 with a user that has admin rights.
I would like to run the program on my LAN on PC#2 at 192.168.168.9. The same user is on this PC with admin rights and the same password.
I'm running a bat file that creates another bat file to run on PC#1.
I run this bat file called UpdateMacriumCreate.bat on PC#1:
It creates this bat file called UpdateMacriumRun.bat on PC#1:
When I run the create bat file it brings up a CMD window and shows that it does run:
When I look on PC#2 at 192.168.168.9 it shows that it's running in Task Manager.
The log file "UpdateMacrium.log" is not created.
This is part of the cmd window:
I do not have the windows firewall running on either PC.
I'm running Win7 32bit Ultimate on PC#1
I'm running Win7 64bit Ultimate on PC#2
Bitdefender did stop it from running on PC#2 the first time and I added that to exceptions.
I have turned off the Bitdefender Antivirus on PC#2
I have fixed most of the problems.
I have two problems left.
1. Echo "Test 5>>UpdateMacrium.log" Is not writing out the file.
2. net use U: "\\192.168.168.7\Dnload\9xAddons\Macrium"
System error 85 has occurred.
The local device name is already in use.
Can anyone help me figure out the solutions for these two problems?
Thank you,
Docfxit
I'm signed on to PC#1 at 192.168.168.7 with a user that has admin rights.
I would like to run the program on my LAN on PC#2 at 192.168.168.9. The same user is on this PC with admin rights and the same password.
I'm running a bat file that creates another bat file to run on PC#1.
I run this bat file called UpdateMacriumCreate.bat on PC#1:
Code: Select all
@Echo On
for /f "delims=[] tokens=2" %%a in ('ping -4 -n 1 %ComputerName% ^| findstr [') do set NetworkIP=%%a
echo Network IP: %NetworkIP%
(
echo: @Echo On
echo: If not exist "C:\Dnload\9xAddons\Macrium" md "C:\Dnload\9xAddons\Macrium"
echo: cd "C:\Dnload\9xAddons\Macrium"
Echo: Echo "Test 1>UpdateMacrium.log"
Echo: tasklist /fi "imagename eq UpdateMacrium.exe" 2>NUL | find /I /N "no tasks are running">NUL
Echo: if "%errorlevel%"=="0" ^(
Echo: echo Task Found
Echo: taskkill /f /im UpdateMacrium.exe
Echo: ^)
Echo: Echo "Test 2>>UpdateMacrium.log"
Echo: tasklist /fi "imagename eq ReflectDLHF.exe" 2>NUL | find /I /N "no tasks are running">NUL
Echo: if "%errorlevel%"=="0" ^(
Echo: echo Task Found
Echo: taskkill /f /im ReflectDLHF.exe
Echo: ^)
Echo: Echo "Test 3>>UpdateMacrium.log"
echo: xcopy /y /f "\\%NetworkIP%\Dnload\9xAddons\Macrium\ReflectDLHF.exe" "C:\Dnload\9xAddons\Macrium\ReflectDLHF.exe"
Echo: Echo "Test 4>>UpdateMacrium.log"
echo: xcopy /y /f "\\%NetworkIP%\Dnload\9xAddons\Macrium\UpdateMacrium.exe" "C:\Dnload\9xAddons\Macrium\UpdateMacrium.exe"
Echo: Echo "Test 5>>UpdateMacrium.log"
Echo: Call UpdateMacrium.exe
) > %~dp0UpdateMacriumRun.bat
c:\batch\psexec.exe @"C:\Batch\PushFileAndRunItComputerList.txt" -i -c -v -s "C:\Dnload\9xAddons\Macrium\UpdateMacriumRun.bat"
cmd /k
Code: Select all
@Echo On
If not exist "C:\Dnload\9xAddons\Macrium" md "C:\Dnload\9xAddons\Macrium"
cd "C:\Dnload\9xAddons\Macrium"
Echo "Test 1>UpdateMacrium.log"
if "0"=="0" (
echo Task Found
taskkill /f /im UpdateMacrium.exe
)
Echo "Test 2>>UpdateMacrium.log"
if "0"=="0" (
echo Task Found
taskkill /f /im ReflectDLHF.exe
)
Echo "Test 3>>UpdateMacrium.log"
xcopy /y /f "\\192.168.168.7\Dnload\9xAddons\Macrium\ReflectDLHF.exe" "C:\Dnload\9xAddons\Macrium\ReflectDLHF.exe"
Echo "Test 4>>UpdateMacrium.log"
xcopy /y /f "\\192.168.168.7\Dnload\9xAddons\Macrium\UpdateMacrium.exe" "C:\Dnload\9xAddons\Macrium\UpdateMacrium.exe"
Echo "Test 5>>UpdateMacrium.log"
net use U: "\\192.168.168.7\Dnload\9xAddons\Macrium"
Call UpdateMacrium.exe
Code: Select all
PsExec v2.2 - Execute processes remotely
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
\\192.168.168.9:
cmd.exe started on 192.168.168.9 with process ID 3952.
C:\Dnload\9xAddons\Macrium>cmd /k
The log file "UpdateMacrium.log" is not created.
This is part of the cmd window:
Code: Select all
C:\Dnload\9xAddons\Macrium>Echo "Test 4>>UpdateMacrium.log"
"Test 4>>UpdateMacrium.log"
C:\Dnload\9xAddons\Macrium>xcopy /y /f "\\192.168.168.7\Dnload\9xAddons\Macrium\
UpdateMacrium.exe" "C:\Dnload\9xAddons\Macrium\UpdateMacrium.exe"
\\192.168.168.7\Dnload\9xAddons\Macrium\UpdateMacrium.exe -> C:\Dnload\9xAddons\
Macrium\UpdateMacrium.exe
1 File(s) copied
C:\Dnload\9xAddons\Macrium>Echo "Test 5>>UpdateMacrium.log"
"Test 5>>UpdateMacrium.log"
C:\Dnload\9xAddons\Macrium>net use U: "\\192.168.168.7\Dnload\9xAddons\Macrium"
System error 85 has occurred.
The local device name is already in use.
C:\Dnload\9xAddons\Macrium>Call UpdateMacrium.exe
I'm running Win7 32bit Ultimate on PC#1
I'm running Win7 64bit Ultimate on PC#2
Bitdefender did stop it from running on PC#2 the first time and I added that to exceptions.
I have turned off the Bitdefender Antivirus on PC#2
I have fixed most of the problems.
I have two problems left.
1. Echo "Test 5>>UpdateMacrium.log" Is not writing out the file.
2. net use U: "\\192.168.168.7\Dnload\9xAddons\Macrium"
System error 85 has occurred.
The local device name is already in use.
Can anyone help me figure out the solutions for these two problems?
Thank you,
Docfxit