I've got a batch file that runs perfectly as a script in K1000. It uninstalls 2 pieces of software, removes desktop icons, Start Menu entries, and Add/Remove Programs entries (the software installer itself doesn't do all those things, dur).

When this batch file is attempted as a post-install task on a K-Image via K2000, it seems to fail to run. I've tried it as a post-install batch file, and have tried zipping it and "call myuninstaller.bat" as an Application post-install task -- it just seems to get skipped over as a post-installation task when imaging.

This problem is not a show-stopper -- I'll get this done another way -- but it makes me worry that I am not fully understanding what K2000 wants out of batch files. Any advice? Thank you in advance!

Here's the text of the script -- again, works as a K1000 script but not as a K2000 batch post-install task:
set _inst=%SystemDrive%\Millennium\UninstallerData\Uninstall Innovative Millennium.exe
set _lnk=Innovative Millennium.lnk
"%_inst%" -silent
if exist "%Public%\Desktop\%_lnk%" del /f /q "%Public%\Desktop\%_lnk%"
set _insto=%SystemDrive%\Millennium\Offline\UninstallerData\Uninstall Innovative Millennium Offline Circulation.exe
set _lnko=Millennium Offline Circulation.lnk
"%_insto%" -i silent
if exist "%Public%\Desktop\%_lnko%" del /f /q "%Public%\Desktop\%_lnko%"
rmdir /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Innovative Millennium"
rmdir /s /q "%HOMEDRIVE%\Millennium"
set "RegKey=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Innovative Millennium"
reg delete "%RegKey%" /f
Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answer Chosen by the Author

2
Your problem is most likely a sequencing problem.  The first uninstall is probably still running when the next kicks off and also the removes and deletes could also be in the running mix.  Try it this way  the last four lines will not execute till the reg delete runs and finishes so the other two uninstalls should no longer referencing anything in those directories either.

set _inst=%SystemDrive%\Millennium\UninstallerData\Uninstall Innovative Millennium.exe
set _lnk=Innovative Millennium.lnk
set _insto=%SystemDrive%\Millennium\Offline\UninstallerData\Uninstall Innovative Millennium Offline Circulation.exe
set _lnko=Millennium Offline Circulation.lnk
set RegKey=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Innovative Millennium

start /wait "%_inst%" -silent

start /wait "%_insto%" -i silent

start /wait reg delete "%RegKey%" /f

if exist "%Public%\Desktop\%_lnk%" del /f /q "%Public%\Desktop\%_lnk%"
if exist "%Public%\Desktop\%_lnko%" del /f /q "%Public%\Desktop\%_lnko%"
rmdir /s /q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\Innovative Millennium"
rmdir /s /q "%HOMEDRIVE%\Millennium"

Answered 05/26/2015 by: SMal.tmcc
Red Belt

  • also your set regkey line had the double quotes in the wrong place
    • SMal.tmcc, thank you! You are correct that start /wait was needed. (Not sure why it is necessary as a postinstall when imaging and not as a standalone script, but on the other hand it does appear tidier and more elegant...)

      So far, I've run it as the very last postinstall task so I can see any errors it may be trying to communicate (don't yet have the skill for further debugging). Everything is pretty much working as expected, though a notice pops up mentioning "Windows cannot find -silent" (but the task still completes). Frankly, I count that as "close enough" though I may try a few more tweaks.

      Thank you!
      • most likely this line is causing the error. start /wait "%_insto%" -i silent. it is seeing the -i as a switch and silent as an unknown option for that switch.
      • the k2000 is mainly an imaging appliance where the k1000 is more of a management appliance and the internal code is very different. The k1000 engineers have worked at correcting things like this automatically for the tech where the k2000 engineers main focus is on multiple OS imaging and scripting.
      • I agree re: -i silent...will try other options. And, makes sense re: K2000/K1000 difference. Thanks!
    • This content is currently hidden from public view.
      Reason: Member has been banned from the site
      For more information, visit our FAQ's.
Please log in to comment

Answers

0
Have you tried adding a few lines of debug code that pipe the value of the different variables you use to a text file?  That will give you at least an idea if the code is resolving correctly.
Answered 05/23/2015 by: EdT
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity