0% found this document useful (0 votes)
111 views

Distributing and Updating Customization Files Automatically

This document summarizes a session on distributing and updating AutoCAD customization files automatically within a corporate environment. It discusses sample software that uses batch files and VBA programs to simplify customization distribution. The speaker demonstrates strategies for handling multiple user profiles, secondary installs, and logon scripts. The document also provides examples of commonly distributed file types, best practices for file locations, and techniques for using AutoCAD profiles and VBA programs to customize the startup environment.

Uploaded by

cadhoc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Distributing and Updating Customization Files Automatically

This document summarizes a session on distributing and updating AutoCAD customization files automatically within a corporate environment. It discusses sample software that uses batch files and VBA programs to simplify customization distribution. The speaker demonstrates strategies for handling multiple user profiles, secondary installs, and logon scripts. The document also provides examples of commonly distributed file types, best practices for file locations, and techniques for using AutoCAD profiles and VBA programs to customize the startup environment.

Uploaded by

cadhoc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

11/30/2005 - 10:00 am - 11:30 am Room:Swan 7/8 (Swan)

Walt Disney World Swan and Dolphin Resort


Orlando, Florida

Distributing and Updating Customization Files Automatically


Thomas Parks - Benchmark Group

CP32-2 This session and demonstration will provide working programs to distribute customization of AutoCAD
within a corporate environment. These programs simplify the task of providing standardized
customization and will be explained so that participants can just tweak the programs or write their own
in-house distribution software. The sample software uses a combination of batch files and VBA
programs to accomplish AutoCAD customization. We will also briefly discuss strategies for handling
multiple user profiles on a workstation, a .Net registry update program, secondary install, the
RoboCopy utility, one-time registry updates, and logon scripts.

About the Speaker:


Tom is system manager at Benchmark Group, an architectural / engineering firm. He writes and
distributes computer programs for over 160 Autodesk Architectural Desktop users. Tom has
programmed professionally since 1978, was an instructor in 1984 at the University of Texas in Austin,
programmed for 9 years at BellSouth, developed automatic software distribution since 1993, and has
written AutoCAD AutoLISP, VBA, and VB.Net programs since 1999. Tom has an M.S. in Computer
Sciences (UT Austin) and a B.A. in Math & Econ/Business (Cornell College).
Distributing and Updating Customization Files Automatically

Expectations
• That you will return to work able to understand, update, and use these techniques to distribute customization files to
networked computers.
• Only Windows NT/2000/XP/2003 addressed

The Basic Plan (One way to use this code where you work)
On a server:
• Create a source directory (“V:\SOFTDIST\ACADuser\R16.2\”) -- This directory will likely have subdirectories
such as "Support". The full version of AU2005.BAT uses two directory trees named "DIST.AUP" and
REPL.AUP". Decide whether you need those two options before you set up the directory tree.
• Fill the source directories with customization files
On every workstation:
• Add a new directory (“C:\ACADuser\R16.2”)
• Customize directories in AU2005.BAT -- the server directory path will certainly need to be corrected. You
may also want to remove the "if" and "echo" commands and anything that is not essential. See file "
\BatchFiles\AU2005bare.BAT" on the CD.
• Update support paths in AutoCAD options (“config”)

• Export new AutoCAD profile (containing custom support paths) -- Use a meaningful name like "auStg.arg".
• Change AutoCAD shortcut icon to use saved profile

• Add AU2005.BAT to the Startup folder -- This will be a shortcut (.lnk) file like "C:\Documents and
Settings\tparks\Start
Menu\Programs\Startup\AU2005.lnk".

2
Distributing and Updating Customization Files Automatically

Commonly Distributed Files


.arg AutoCAD profiles .dwt drawing templates
.arx ARX programs .hdi,.pc3,.pmp pen & plotter settings
.atc tool palettes .lsp lisp programs
.bat batch files .mnc,.mnr,.mns menus
.bmp,png image files .pat hatch patterns
.ctb pen & plotter settings .Reg registry files
.dcl dialog control language .SCR scripts
.dll .Net programs .SHX font files
.dvb VBA programs .txt text files
.dwg drawings

Choosing Best Location for Customization Files


The “Documents and Settings” Directories?
It is assumed that your workstations have local user profiles. This contains the Windows profile directories, one for each user
that has logged on to this computer.
• Files are difficult to find
• Files are duplicated, wasting copying effort and disk space
The “Program Files” Directory?
This directory contains the AutoCAD computer program files shared by all users.
• Files get mixed with standard AutoCAD files
Central Server Directory?
Autodesk suggests an option where you add a server directory to your AutoCAD file search paths. It works in many situations,
and has the great advantage that no distribution necessary. We had a few minor concerns about extra network traffic at startup
or intermittent network failures. When people started running AutoCAD on laptops while on the road, this technique was no
longer applicable.
Custom Workstation Directory (“C:\ACADUser\V16.1\”)
We create a new directory for our customization files. This provides a simple, short directory path, making it easy to find and
share customization files. There is only one copy per workstation. It is the same for desktops and laptops. It does, however,
assume local administrator access rights for all users or some other access rights solution. (Search for help on "NTFS
permissions".)

In-House vs. Vendor Solutions


We had a goal that anyone could distribute customization files without knowing how the process works. Some vendor solutions
provide complex ways to distribute software, and could not meet that goal. You may have only a few people that should be
distributing software, and a more complex installation process may work for you. The advantage of using a vendor product is
that you avoid the development time associated with writing your own software; your development time is spent on an already-
documented setup process.

Miscellaneous Customization Tasks -- What they are and how they work
These samples are on the CD. InstallREG.bat – installs a registry file only once; it is called by AU2005.bat. AutoCAD profiles
can be used to share toolbar layouts and files search paths. The Acad.DVB file provides an example of a VBA program that
runs during AutoCAD startup. The ADT2005PostInstall.bat forces a repeat of AutoCAD's secondary install.
DotNetAutoload.exe creates a registry update file for .Net programs.

3
Distributing and Updating Customization Files Automatically

InstallREG.bat -- The registry update program


01] @echo off
02]
03] if %2.==. goto Parms
04]
05] set InstallREGI="%TMP%\%2"
06] if exist %InstallREGI% goto SkipRI
07] regedit /s /i %1
08] Echo Attempted Registry Import of %1 >%InstallREGI%
09] :SkipRI
10]
11] goto Exit
12]
13] :Parms
14] Echo.
15] Echo Parameters: Path to registry file
16] Echo Name of indicator file (Created by this program)
17] Echo.
18] Echo.
19] Echo Example:
20] Echo InstallREG c:\batch\GoodStuf.reg GoodStuff.txt
21] Echo.
22] Echo.
23]
24] goto Exit
25]
26] :Exit

The sample execution of this batch file is on line 20. Note that the parameters "c:\batch\GoodStuf.reg" and
"GoodStuff.txt" appear in the program as "%1" and "%2". Line 07 contains the main code: “regedit”. The parameter “/s”
indicates a silent execution, “/i” indicates an import, and “%1” is the first parameter to the call. For more information, search for
“regedit” at "http://support.microsoft.com/". Other commands will provide their own help information by adding a "/?" parameter.
(For example, typing "if /?" in a command window shows extensive help information for the "if" command.) Line 06, 08, and 09
show that the report file is also a semaphore -- that is, it signals that this registry update has already been completed.

AutoCAD Profiles -- A way to distribute toolbar layouts


From AutoCAD help files: The user profile file contains drawing environment settings such as screen color, cursor size,
command line window font, and the AutoCAD search folders.
“Set Current” -- Activates the selected profile.
“Export” -- Saves the active (not necessarily the selected profile) to a file.
“Import” -- Copies a profile from a file. Does not make it active.
Benchmark Group uses profiles to set the search directories. However, if you are using a network install of AutoCAD, you might
be wise to use that AutoCAD network install customization tool to set the search directories.

Acad.DVB -- Load and execute every time you start AutoCAD


You can learn more about VBA programs that execute at startup -- see the AutoCAD help page “Automatically Load and
Execute VBA Projects”. The CD Sample file Acad.DVB has a startup process that forces Imperial Units (not metric) and sets
the current AutoCAD profile. (There are other ways to set the profile initially.) To allow the startup program to execute, the VBA
environment must be loaded:
Add (arxload "AcVba.arx") to file acaddoc.lsp
or
Add acvba.arx to file acad.rx

4
Distributing and Updating Customization Files Automatically

ADT2005PostInstall.bat -- Start over for this user


Like many programs, AutoCAD has both a primary and secondary installation process. The primary install occurs once for each
workstation. The secondary install occurs for each user on a workstation. The secondary install initializes many AutoCAD
settings. When a user changes something and AutoCAD starts misbehaving, we run this program to force a secondary install
that restores the defaults.
@echo off
reg delete HKCU\Software\Autodesk\AutoCAD\R16.1\ACAD-304:409 /f

C:
cd "\Program Files\Autodesk Architectural Desktop 2005"
acad.exe /p "C:\ACADuser\R16.1\Support\bgstd.arg"

DotNetAutoload.exe -- Registry update for .Net programs


To use a DotNET program in AutoCAD, the program must be loaded with a "NETLOAD" command. We do not normally want
to require users to run NETLOAD with a possibly long program path name. Autodesk tells how to patch the registry to
automatically load your DotNET program. DotNetAutoload.exe creates a “.reg” file to insert the autoload registry entries. It asks
you to specify the version of AutoCAD and searches VB.Net program for “CommandMethod” entries. Another way to do this
might be to create a setup project in .Net. There are samples on the CD. Note: double-clicking a ".reg" file installs the updates.

5
Distributing and Updating Customization Files Automatically

The Distribution Program - What it is and how it works

Set the “Path” environment variable


We have a standard directory named “Batch” where we put our in-house programs. To make it easier to run these programs,
we add “C:\Batch” to the Windows environment “path” variable. See the “Control Panel ” / “ System Properties ” / “Advanced” /
“Environment Variables” / “Edit”.

RoboCopy Overview
Five types of files
Type Description RoboCopy action
Lonely exists in source only Normally copied
Extra exists in target only deleted only if using the /MIR parameter
Newer newer in target Normally copied unless using the /XN parameter
Older older in target Normally copied unless using the /XO parameter
Same source same as target Normally ignored

ROBOCOPY SourceDirectory DestinationDirectory [options]

Favorite options:
/S -- copy Subdirectories /IS -- Include "Same" files.
/MIR -- Mirror (delete "Extra" files) /R:n -- number of Retries (default 1 million)
/XN -- Exclude "Newer" files. /L -- List only - make no changes
/XO -- Exclude "Older" files. /NP -- No Progress - don't display % copied.
/XX -- Exclude "Extra" files/directories. /LOG+:file -- append output to log file
/XL -- Exclude "Lonely" files/directories.

6
Distributing and Updating Customization Files Automatically

The Distribution Program -- AU2005.BAT


01] echo ACAD 2005 File Maintenance >"%TMP%\GetSW.rpt"
02] set AppName=ADT 2005
03] if exist "%USERPROFILE%\Application Data\Autodesk\%AppName%\enu\Support\acad.mnl" goto ADT2005
04] set AppName=Autodesk Architectural Desktop 2005
05] if exist "%USERPROFILE%\Application Data\Autodesk\%AppName%\enu\Support\acad.mnl" goto ADT2005
06] goto NADT2005
07] :ADT2005
08] if not exist C:\ACADuser\R16.0\bgpens\*.* md C:\ACADuser
09] RoboCopy "C:\SoftDist\DIST.AUP\ACADuser" "C:\ACADuser" *.* /S /R:0 /NP /XO >>"%TMP%\GetSW.Rpt"
10] RoboCopy "C:\SoftDist\REPL.AUP\ACADuser" "C:\ACADuser" *.* /S /R:0 /NP >>"%TMP%\GetSW.Rpt"
11] :NADT2005
12]
13] Echo Patch ADT 2005 Registry Settings
14] call InstallREG "C:\ACADuser\R16.1\Support\ADT2005aecDefaults.reg" "ADT2005aecDefaults.txt"
15]
16] Echo Autoload BG DotNET ADT 2005 Customization
17] call InstallREG "C:\ACADuser\R16.1\Support\NetAutoloadLyrMimic.reg" "LyrMimic.txt"
18]
19] Echo. >>"%TMP%\GetSW.Rpt"
20] Echo Ended software distribution. >>"%TMP%\GetSW.Rpt"
21] Echo. >>"%TMP%\GetSW.Rpt"

Line 10: “RoboCopy” is the program that performs the bulk of the software distribution in our plan. This is a free download from
Microsoft (note the internet shortcut on the CD-ROM. If that link fails, try searching microsoft.com for "RoboCopy download" or
"Windows Server 2003 Resource Kit Tools").
Line 09: This RoboCopy uses a different source directory ”DIST.AUP” that will copy only new files or those more-recently
updated. If the user updates a file to be younger than the distributed version, however, it will not be overwritten. The “/XO”
parameter tells RoboCopy to exclude older files; it keeps RoboCopy from overwriting younger files. More details on RoboCopy
parameters are on the preceding page. There is an excellent document that is included in the resource kit, and "RoboCopy /?"
also provides extensive help.
Line 08: This lines creates the target directory if it does not already exist. See help on the "if" command to learn more about
"exist" and "not".
Line 02-07,11: Not all workstations need the distributed software. These lines of code check for signs of an AutoCAD install and
skip to or over the copy commands accordingly. This may not be useful for your situation.
Lines 13,14: Update registry settings to ensure that AutoCAD uses the correct drawing units. (This may not be the best way to
do that now. Note that there may be other tasks that you want to include with your daily batch file. For example, years ago,
before the time of email and browsing, we used the daily batch file to display a message of the day.)
Lines 16,-17: Update registry settings to autoload a DotNET program. The registry file and a way to create it are covered
elsewhere.
Lines 01, 19-21: The echo commands and the redirection of the RoboCopy report to a file is to provide some debugging
information. For example, if the user reboots while the autoupdate is in progress, the final message of the echo commands will
not appear in the log file.

7
Distributing and Updating Customization Files Automatically

Execution Techniques: User’s “Startup” folder


Benchmark Group places a shortcut in the user’s startup directory to run the autoupdate program. We actually place this in the
“Default User” profile directory so that first-time users on a workstation will automatically get the shortcut. Often this can be done
remotely , for example "Copy au2005.bat \\wkstation\c$\Documents and Settings\userid\Start Menu\Programs\Startup".

Execution Techniques: Scheduled Task


You can use the “SchTasks” utility or Control Panel to create a scheduled task. You could schedule an early-morning task if your
workstations are left on all night. This technique avoids users waiting for the autoupdate to complete or canceling it when they
get impatient. Note that this only makes sense with a shared target directory. (How would you copy to Windows profile
directories?) The "SchTasks" utility in the resource kit with RoboCopy is helpful for managing scheduled tasks. You can even
schedule tasks on other workstations. Use “net view” to show all the local workstation names and “SchTasks /s” to schedule on
another system. “SchTasks /?” provides help. Your command might look like "SchTasks /create /tn AU2005 /tr c:\batch\
AU2005.bat /sc DAILY /st 01:02:59". While Benchmark Group does not use this method since we update profile information, it
appears to be the best solution.

Execution Techniques: Logon Script


You can set up a user’s logon script to call the update batch file or just use the AU2005 as your logon script. You can also “call”
the autoupdate program from a logon script (\\ServerName\NetLogon\ls.bat). Note that if you log on to a server, a logon script
will execute on the server.

Execution Techniques: Group Policy


You can also set up a user’s logon script via Group Policy at the Windows Active Directory level. You can use Group Policy to
force the logon script for multiple users. Alternately, you could force a startup script for a set of computers.

8
Distributing and Updating Customization Files Automatically

Next Version -- How to modify this code for AutoCAD 2006, or (How to use this
code where you work)
• Add new version directory (“R16.2” for AutoCAD 2006)

• Add different registry entries and different directory names to ADT2005PostInstall.bat ("16.1" becomes "16.2"; "ACAD-
304:409" becomes "ACAD-404:409"; and "\Autodesk Architectural Desktop 2005" becomes '"\Autodesk Architectural
Desktop 2006".)
• Change directories or add new directories in AU2005.BAT. (See the CD file "\BatchFiles\AU2006.BAT".)

• Update support paths in AutoCAD options (“config”)


• Export new AutoCAD profile (containing custom support paths)

Next Year’s AU -- What would you like to hear?


• Class evaluation forms help you choose what classes are offered again.
• Conference evaluations can suggest new topics you would like to hear.
Suggestions:
“Supporting Your Users”
“The Software Development Cycle”

You might also like