We help IT Professionals succeed at work.

Batch File: .NET v4 remote install

ReneGe
ReneGe used Ask the Experts™
on
Hi there,

I scripted a batch file that will install .NET 4.0, if v2 or higher is not already installed on any of the LANs PCs, that the name starts with \\PC.

The script works, but the install command line fails to install .NET

Thanks for your help,
Rene
@ECHO OFF
SETLOCAL enabledelayedexpansion

SET MustUpdate=Yes
SET NetworkFolder=\\Server\Installz$\DotNet4
SET LogFile=%NetworkFolder%\%~n0.log
SET LogFileTMP=%NetworkFolder%\%~n0_TMP.log

DEL /F /Q "%LogFile%" >nul 2>&1
DEL /F /Q "%LogFileTMP%" >nul 2>&1

FOR /F %%A in ('NET VIEW ^| Findstr -i "\\PC"') DO (
	ECHO QUERING %%A
	FOR /f "delims=" %%B IN ('reg query %%A\HKLM\SOFTWARE\Microsoft\.NETFramework\Policy ^| FINDSTR -i "v2 v3 v4"') DO SET MustUpdate=No
	IF !MustUpdate! EQU Yes (
		ECHO %%A>>"%LogFile%"
		ECHO ---------------------->>"%LogFile%"
		PSEXEC %%A "%NetworkFolder%\dotNetFx40_Full_x86_x64.exe" /q /log "%LogFileTMP%"
		TYPE "%LogFileTMP%">>"%LogFile%"
		ECHO.>>"%LogFile%"
		ECHO.>>"%LogFile%"
		DEL /F /Q "%LogFileTMP%" >nul 2>&1
	)
	SET MustUpdate=Yes
)

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Have you tried to execute from a local folder instead of a network folder ? I think there are problems on using remote folders on MS-Dos.

Also, ensure you are executing the batch from Windows Administrator user.

Hope it helps. Regards.

Author

Commented:
Forgot about that one.
That was it. Thanks G  ;-)
Happy to help. Thank you for your comments and your evaluation.

Regards.