confirmation on batch script

Hello colleagues,

I have this one script to install firefox
psexec @clients.txt "c:\updates\firefox.exe" -ms 

Open in new window


however how would I translate and integrate the following idea?
result=0
if  error code==0 then %result%=success else %result%=failed >>%client%,%result%.csv

Open in new window


so I can get an output like this
Capture.PNG
of if anybody has a better idea would also work?
LVL 4
ivan rosaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
psexec @clients.txt "doit.bat"

Open in new window

doit.bat
set resultfile=\\server\share\firefoxrslt.csv
"c:\updates\firefox.exe" -ms 
if errorlevel 0 then (
  echo %computername%,success>>%resultfile%
) else (
  echo %computername%,failed>>%resultfile%
)

Open in new window

ivan rosaAuthor Commented:
I just tried but it gave me an error,

PsExec could not start doit.bat on computer1

if I did doit.bat itself then will start the installation on the computer trying to launch it

and yet even though it gave me an error I didn't get any results...
NVITEnd-user supportCommented:
psexec @clients.txt -c -f "doit.bat"

Open in new window

Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

NVITEnd-user supportCommented:
if you do this in a cmd window:
"c:\updates\firefox.exe" -ms
echo %errorlevel%

Open in new window

...one of the the IF lines should be true.
ivan rosaAuthor Commented:
we got passed the install now, although the result is still not showing up...
NVITEnd-user supportCommented:
Can it see firefox.exe? Move it to a share...
set resultfile=\\server\share\firefoxrslt.csv
"\\server\share\updates\firefox.exe" -ms 
if errorlevel 0 then (
  echo %computername%,success>>%resultfile%
) else (
  echo %computername%,failed>>%resultfile%
)

Open in new window

Bill PrewIT / Software Engineering ConsultantCommented:
I didn't think firefox.exe returned negative errorlevel's, so won't this always be true?

if errorlevel 0 then (

~bp
ivan rosaAuthor Commented:
firefox returns 0 for success and other than that is a failed unless if is directly from a psexec command will give something like 1xxx

so I just recreated something else again and this actually writes a file but the content is not quiet there yet

commander
for /f %%a in (clients.txt) do doit.cmd %%a

Open in new window


doit
"c:\updates\firefox.exe" -ms 
if %ERRORLEVEL% EQU 0 echo.%%a,success>>result.csv
if %ERRORLEVEL% NEQ 0 echo.%%a,failed>>result.csv

Open in new window


although the result it gives me is

and it doesn't collect the actual computer name from the variable...
%a      success
%a      success
Bill PrewIT / Software Engineering ConsultantCommented:
Try this, the %%a gets passed to doit.bat as the first command line parm, so is referenced in doit.bat as %1.

"c:\updates\firefox.exe" -ms 
if %ERRORLEVEL% EQU 0 (
  echo.%1,success>>result.csv
) else (
  echo.%1,failed>>result.csv
)

Open in new window

~bp
Lee W, MVPTechnology and Business Process AdvisorCommented:
Let me suggest an alternative solution that is far more expansive and easier... while not free, it's very inexpensive and no long term commitment (though I think HIGHLY worth the price).

Try Ninite - www.ninite.com - the Pro version can be scripted and also deploy to machines it finds in AD all at once.
NVITEnd-user supportCommented:
I use PDQ Deploy. The trial version will work across the domain. You just can't schedule it. The trial version can choose 3 packages. In your case, one would be Firefox.
ivan rosaAuthor Commented:
I wish I could use a third party software.. aaah!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ivan rosaAuthor Commented:
never found the right answer...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.