# Solved: Perform PSExec 3 times in case of failure using for loop 2) logic to write



## Phanikiran (Jul 28, 2014)

Perform PSExec 3 times in case of failure using *for loop*
HI foxidrive how can we implement the below requiement in the code below

1)	Perform PSExec 3 times in case of failure using for loop
2) logic to write in to database .

echo psexec -n 300 -h -s \\%%a cmd /c "title %%a&hostname&echo Running Simple Update...&cd \localbin\&supdate -%1">>C:\Temp\%%a.cmd
echo if %%ERRORLEVEL%% NEQ 0 echo.Error in performing the psexec on %%a on %%date%% %%time%% ^>^>"SimpleUpdateLogs/SimpleupdateErrorlogfile - %%date:/=-%%.txt">>C:\Temp\%%a.cmd
echo if %%ERRORLEVEL%% EQU 0 echo.Sucesss in performing the psexec on %%a on %%date%% %%time%% ^>^>"SimpleUpdateLogs/SimpleupdateSuccesslogfile - %%date:/=-%%.txt" >>C:\Temp\%%a.cmd


----------

