Link to home
Start Free TrialLog in
Avatar of ReneGe
ReneGeFlag for Canada

asked on

Batch File: "Port Reporter" Remote installation

Hi there,

I did this batch file to install Port Reporter on all PCs on my network.

Everything in this script works, but the installation fails with an error code 1.

By the way, I am a Domain Admin.

Could you please tell me what I did wrong?

Thanks for your help,
Rene
@ECHO OFF

SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F %%A IN ('net view ^| findstr \\PC') DO (
	ECHO %%A
	SET Destination=%%A\c$\Temp\PortRptr
	IF NOT EXIST "!Destination!" MD "!Destination!"
	COPY ".\PortRptr" "!Destination!"
	PSEXEC %%A C:\Temp\PortRptr\pr-setup.exe /a /s
	IF !errorlevel! NEQ 0 (ECHO %%A FAILED>>%~n0.log) ELSE (ECHO %%A SUCCESS>>%~n0.log)
	RD /S /Q "!Destination!"
)

PAUSE

Open in new window

Avatar of Bill Prew
Bill Prew

Where do you see the error code?  Can you tell if the setup.exe program actually gets started on the remote PC, or not?

~bp
Avatar of ReneGe

ASKER

I see the error code on screen
Also in the log file
@echo off

SETLOCAL ENABLEDELAYEDEXPANSION

FOR /F %%A IN ('net view ^| findstr \\PC') DO (
	ECHO %%A
	SET Destination=%%A\c$\Temp\PortRptr
	IF NOT EXIST "!Destination!" MD "!Destination!"
	COPY ".\PortRptr" "!Destination!"
	PSEXEC %%A C:\Temp\PortRptr\pr-setup.exe /a /s
	SET Result=!errorlevel!
	IF !Result! NEQ 0 (ECHO %%A FAILED [!Result!]>>%~n0.log) ELSE (ECHO %%A SUCCESS>>%~n0.log)
	RD /S /Q "!Destination!"
)

PAUSE

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ReneGe

ASKER

Yes to all

Thanks,
Rene
Not sure then, you running the latest PSEXEC, I read that there were some quirks with the errorlevel in early versions.

~bp
Avatar of ReneGe

ASKER

I'll look at it. Will let you know.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ReneGe

ASKER

==>aleinss

Thanks, did'nt think of that one.

I'll test and come back!

Cheers,
Rene
Avatar of ReneGe

ASKER

==>aleinss

Still does not work

Thanks for your contribution

Cheers,
Rene
Avatar of ReneGe

ASKER

==> billprew

My version was 2008. I updated it and still same problem.

I can't put more time on this so I'll close this threar and distribute points considering the level of contribution.

Thanks guys,
Rene
Avatar of ReneGe

ASKER

If you have any further odeas, would you mind sharing?

Thanks and cheers,
Rene
Rene,

Thanks for the credit, sorry I wasn't more help on this one.

~bp
Avatar of ReneGe

ASKER

It' cool Bill!

Cheers,
Rene