Could not start PsExec service on remote: The system cannot find the file specified

0

Here is the script I have compiled:

@echo off
REM This file assumes you have psexec installed
REM Ask for machine name or IP
set /p machine= Please enter the machine name or ip:
REM check for workstation online, if not exit
ping %machine% | find "Reply"
if errorlevel 1 goto :offline
if errorlevel 0 goto :install

:offline
echo Workstation not online
pause
exit

:install
xcopy "w:\*****\*****\psexec.exe" \\%machine%\c$\windows\system32
xcopy "w:\*****\*****\*****\*****\fix.reg" \\%machine%\c$\temp
PsExec -s -i \\%machine% -u domainadmin \\%machine%\c$\windows\regedit.exe -i "c:\temp\fix.reg"
pause

<< Reg file  fix.reg>>
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]

The script is working down to the point where it has copied the files from the network to the remote computer. I then get asked for the domain admin password PsExec starts then I get the message:

Could not start PsExec service on Computername: The system cannot find the file specified.

I can run the .reg file by remoting onto the computer and double clicking it but there has to be a way to get PsExec to run it remotely

\\%machine%\c$\temp\fix.reg psexec -s \\%machine%\c$\windows\system32\reg.exe

The first half of this line is working correctly, it runs the reg file but rather than updating the registry on the target computer it updates my local pc registry can anyone see the issue?

Paul508

Posted 2016-05-04T10:36:09.740

Reputation: 35

Could you post the script how it is exactly without your password info? – NetworkKingPin – 2016-05-04T10:44:49.477

This is the line that seems to be causing an issue as the rest runs correctly: PsExec -u DomainAdmin \%machine% regedit -s "c$\temp\fix.reg" – Paul508 – 2016-05-04T11:43:58.797

Fixed it, I had PsExec in the wrong place, swapped it to this: \%machine%\c$\temp\fix.reg psexec -u -p and now it works a treat :-) – Paul508 – 2016-05-04T12:09:24.497

Please read Can I answer my own question?. You might want to convert your comment into an answer ;)

– DavidPostill – 2016-05-04T14:34:03.240

It didn't fix it :-( Its now very confusing, %machine% is recognised all the way through the script as the machine that's typed in on line 4 but is recognised as the local machine when executing the .reg file – Paul508 – 2016-05-05T11:00:05.650

Rewrote my script to this: – Paul508 – 2016-05-17T14:02:01.100

running this line \%remotemachine%\c$\temp\OfficeDocumentfix.reg I get a pop up box asking me if I trust the location, I select yes then I get a message to say it has updated the registry, problem is it updates my local computer registry rather than the remote computer, can anyone help? – Paul508 – 2016-05-17T14:07:42.643

No answers