Lately I’ve been working on deployments for one of our larger customers. There are six products, each with 32-bit and 64-bit deployments, as well as CAD Masters’ own Standards Manager and requisite VBA for Autodesk products. Needless to say that’s a lot of different deployments to be launching, not to mention creating folders, changing icons and doing it all in the right order!
To achieve some automation for the whole thing, I’ve been using batch files. I’m sure many of you know batch files better than I do, but for those that don’t, batch files are text files used to run dos commands. It’s easy to create a batch file that will call each deployment in order. It can be as simple as this:
call “c:\deployments\C3D\Civil 3D 2011.lnk”
call “c:\deployments\ACAD\AutoCAD 2011.lnk”
call “c:\deployments\VBA\VBA 2011.lnk”
The call command should execute and then return to the next line after completion. In other words, after Civil 3D installs, the next line would start the installation of AutoCAD. However, what I found with the deployments was that they returned too early. AutoCAD would try to install before Civil 3D was done and fail. The reason is that each deployment calls different setup.exe processes. When the first one finishes, the batch file executes the next command. I needed the batch file to wait for Civil 3D to finish installing before beginning the AutoCAD install. Some web searching and learning returned the following solution to my problem.set tempfile=tmp.txt :IsRunning PING 184.108.40.206 -n 1 -w 10000 >NUL del %tempfile% tasklist > %tempfile% type %tempfile% | find /i “setup.exe” if errorlevel 0 if not errorlevel 1 goto IsRunning
That little piece of code did the trick. Let me explain the lines a little bit:1. Sets a temp file to be used later. 2. Defines a point to return to later. 3. Waits 10 seconds (no easy way to pause in a batch file). 4. Clears the temporary file. 5. Puts the task list (all running programs) into the temporary file. 6. Searches the temporary file for setup.exe 7. Moves on if setup.exe isn’t running. Goes back to line 2 if it is.
You could put that code in another batch file and call it between each deployment. Problem solved.