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

asked on

BatchFile: Simultanious execution

Hi there,

I just did this batch file that will simultaniously SET the time on the network computers.

If I remove the ping delay line, it is faster, but I get misc errors.

For example, I some times get findstr file not found...

I need to improve this batch file so the simultanious execution is faster, without the errors.

Thanks,
Rene

@ECHO OFF
SETLOCAL EnableDelayedExpansion

SET LogFile=%~n0.log
SET TmpFolder=%~dp0%~n0_TMP

IF EXIST "%TmpFolder%" RD /s /q "%TmpFolder%"
IF NOT EXIST "%TmpFolder%" MD "%TmpFolder%"
IF EXIST "%LogFile%" DEL "%LogFile%"

FOR /F "delims=" %%T in ('TIME /t') DO SET TheTime=%%T

FOR /F "delims=\ " %%A IN ('NET VIEW ^| FINDSTR -i "\\" ^| FINDSTR -i -v "%computername%"') DO (
	SET BatchFile=%TmpFolder%\%%A.bat
	ECHO %%A
	ECHO psexec \\%%A cmd /c time %TheTime%>>"%LogFile%"
	ECHO psexec \\%%A cmd /c time %TheTime%>>"!BatchFile!"
	ECHO EXIT>>"!BatchFile!"
	START "SET NETWORK TIME" /min "!BatchFile!"
	PING -n 1 -w 10 10.0.0.0 >NUL
)

EXIT

Open in new window

SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

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

Thanks Q for your help.

I did try "NET TIME \\TIMESRV /SET /YES".

But the time on few non domain controller servers, keeps going back to + or - 1h.

PS: We are located at -5 GMT and time shifted 1h this weekend.

Have any ideas?

Cheers,
Rene
ASKER CERTIFIED 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

Case resolved :)

http://support.microsoft.com/kb/2633952 + w32tm /resync /rediscover

Thanks Q and oBdA

Cheers,
Rene