Showing posts with label VBScript. Show all posts
Showing posts with label VBScript. Show all posts

Monday, July 15, 2013

Security Hotfix: Autodesk AutoCAD Code Execution Vulnerability

This hot fix addresses a vulnerability that could lead to an arbitrary code execution when loading specifically crafted DWG files. The vulnerability has a Common Vulnerabilities Exposure (CVE) ID CVE-2013-3665. For more information, please visit the CVE dictionary at as well as this detailed paper.

This Hotfix works with supported versions (see readme) of AutoCAD 2011-2014, AutoCAD LT 2011-2014, DWG TrueView 2011-2014, and associated verticals. Download it here. Files affected are acdb18.dll, acdb19.dll, AcSignCore16.dll and AdApplicationFrame.dll.

Note that when the script is run it will kill explorer.exe and restart it when ready.

But I got problem to run this.

Windows Script Host displayed this error:
Script:    C:\Users\<user>\AppData\Local\Temp\BufferOverrunHotfix\Hotfix.vbs
Line:    556
Char:    5
Error:    Permission denied
Code:    800A0046
Source:     Microsoft VBScript runtime error

Afterward Explorer had to be started manually.

I looked at the log file %temp%\BufferOverrunHotfix.log and found this as the last row:
Applying Hotfix file AcSignCore16.dll from: C:\Users\<user>\AppData\Local\Temp\BufferOverrunHotfix\files\\x64\ to: C:\Program Files\Common Files\Autodesk Shared\

I then used Process Explorer and searched for AcSignCore16.dll and found that the process KeePass.exe used it so I killed it and after that I successfully could run the complete hotfix.

If you want to distribute this hotfix on many computers run it on a test computer and then grab the files found in %TEMP%\BufferOverrunHotfix. HotfixLauncher.vbs and Hotfix.vbs can be edited as needed.

UPDATE: This hotfix is included in AutoCAD 2014 Service Pack 1.

Thursday, June 21, 2012

ACAD/Medre.A Malware AutoCAD AutoLISP Malware!

ACAD/Medre.A – 10000′s Of AutoCAD Files Leaked in Suspected Industrial Espionage

According to ESET Threat Blog here and here:

An AutoCAD worm, written in AutoLISP, the scripting language that AutoCAD uses, suddenly showed a big spike in one country on ESET’s LiveGrid® two months ago, and this country is Peru.

The main motive of the malware is to steal AutoCAD drawings from the infected system. These are sent to the attacker via email. Apart from the stolen drawings, some additional information is also sent.

ACAD/Medre.A is a serious example of suspected industrial espionage. Every new design created by a victim is sent automatically to the authors of this malware. Needless to say this can cost the legitimate owner of the intellectual property a lot of money as the cybercriminals will have designs before they even go into production by the original designer. The attacker may even go so far as to get patents on the product before the inventor has registered it at the patent office. The inventor may not know of the security breach until his patent claim is denied due to prior art.

You can download the ACAD/Medre.A removal tool here.

The sample is able to infect versions 14.0 to 19.2 of AutoCAD by modifying the corresponding native startup file of AutoLISP (acad.lsp) by being named as the auto-load file acad.fas. It employs Visual Basic Scripts that are executed using the Wscript.exe interpreter that is integrated in the Windows operating system since Windows 2000. The author assumes that his code will even work for future versions of AutoCAD as it has support for the AutoCAD versions that will be released in 2013, 2014 and 2015.

The Autodesk Knowledge Base article TS19860569 says:

What is the nature of the malware?

ACAD/Medre.A is an AutoLISP program disguised as an acad.fas file. When a user opens a DWG from a folder containing this file, the malware sends a copy of the DWG via an email (using SMTP protocol). For additional information on an AutoLISP based malware, visit: AutoCAD and Viruses.

ACAD/Medre.A is also known as: ALisp/Blemfox.A (Microsoft), Trojan.Acad.Bursted.W (BitDefender), ALS.Bursted.B (Symantec).

Which Autodesk products may be affected?

The malware targets AutoCAD releases 2000 and newer, and other products based on AutoCAD. AutoCAD LT, AutoCAD for Mac and other Autodesk products are not affected.

How can I know if my system is infected?

The malware is easily detectable by major antivirus solutions with up-to-date virus definitions. We recommend users perform a full virus scan to see if their system is infected by this malware.

There are alternative methods of detecting possible infections by this malware:

  • acad.fas or cad.fas files on your system may indicate the presence of this malware.  You can search for these files in Windows Explorer.  Since these files could be hidden, you may need to show hidden files using the following Microsoft solution:Show Hidden Files.
  • Search for the acad.fas from the AutoCAD command line by typing (findfile "acad.fas"), including parenthesis.

If the search finds a match, compare an MD5 or SHA-1 cryptographic hash of the discovered acad.file with - md5: 7b563740f41e495a68b70cbb22980b20; SHA1: 3ea33bedadc9bfc92c570b316b78b6fd9787f09.  If MD5 or SHA-1 hash values match, your system is infected.   For more information on how to compute an MD5 or SHA-1, see: How to compute the MD5 or SHA-1 cryptographic hash values for a file.

How can I remediate the infection?

This malware can be remediated through leading commercial antivirus solutions. Autodesk has confirmed that Microsoft, Trend Micro, McAfee, Symantec, and Kaspersky antivirus solutions can clean this malware. We have also verified that ESET’s ACAD/Medre.A stand-alone cleaner can clean this malware.  We will update this FAQ as we test additional antivirus solutions.

What best practices can I follow to reduce my chances of being infected?

We recommend users protect their systems through use of an antivirus solution with up-to-date virus definitions. In addition, the following best practices can reduce the chance of an infection:

  • Do not open archive files (i.e. zip) from unknown users. 
  • Do not run an unknown AutoLISP file without inspecting it first.
  • The following Autodesk knowledge base article also provides additional best practices:
    AutoCAD and Viruses

On the topic of viruses: Acad.vlx Virus Cleanup improved, AutoCAD and DWG viruses made in VBA or AutoLISP and AutoCAD Adware Trojan

Wednesday, April 4, 2012

How to start a VBS file using AutoLISP

If you in AutoCAD want to start a VBScript file with AutoLISP here are three ways where the variable app holds the full path to the VBS file:

(startapp "WSCRIPT.EXE" (strcat "\"" app "\""))

(command "START" app)

(if (setq WScript (vlax-get-or-create-object "WScript.Shell"))
  (vl-catch-all-apply 'vlax-invoke-method (list WScript "Run" app 1 :vlax-true))

If the START command is used you will quickly see the AutoCAD Shell so I prefer to use the startapp function.

If the path contains spaces like (C:\\Folder A\\test.vbs) the startapp function must have the path with double quotes like the snippet above, otherwise the Windows Script Host will show this error: There is no file extension in "C:\Folder".

Some of this works with starting or running other files (EXE, BAT, CMD,…) or open files in their associated application. See also how to Start a Windows application within AutoCAD.

Thursday, December 9, 2010

Automated uninstallation of AutoCAD with VBScript

This will completely remove AutoCAD 2011 and related plug-ins.

The VBScript will detect and uninstall 32-bit or 64-bit versions of English AutoCAD 2011 and language pack.  It will also provide the option to uninstall the following plug-ins (if found):

  • AutoCAD 2011 Subscription Advantage Pack
  • AutoCAD WS plug-in for AutoCAD 2011
  • AutoCAD 2011 VBA Enabler

If you have multiple AutoCAD 2011-based products installed, these modules may be in use by more than just AutoCAD 2011.  Do not uninstall them if they could be in use elsewhere.

The VBScript will then remove folders and registry keys related to the uninstalled product and plug-ins.

See KB: TS16077500

'============================================================================ ' Uninstall_ACAD_2011.vbs ' This script is designed to uninstall AutoCAD 2011 and remove installed plug-ins ' ' Copyright © 2010 by Autodesk, Inc. All Rights Reserved. ' ' You are hereby granted permission to use, copy and modify this ' software without charge, provided you do so exclusively for ' your own use or for use by others in your organization in the ' performance of their normal duties, and provided further that ' the above copyright notice appears in all copies and both that ' copyright notice and the limited warranty and restricted rights ' notice below appear in all supporting documentation. ' ' Incorporation of any part of this software into other software, ' except when such incorporation is exclusively for your own use ' or for use by others in your organization in the performance of ' their normal duties, is prohibited without the prior written ' consent of Autodesk, Inc. ' ' Copying, modification and distribution of this software or any ' part thereof in any form except as expressly provided herein is ' prohibited without the prior written consent of Autodesk, Inc. ' ' AUTODESK PROVIDES THIS SOFTWARE "AS IS" AND WITH ALL FAULTS. ' AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF ' MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, ' INC. DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE ' WILL BE UNINTERRUPTED OR ERROR FREE. ' ' Restricted Rights for US Government Users. This software ' and Documentation are provided with RESTRICTED RIGHTS for US ' US Government users. Use, duplication, or disclosure by the ' Government is subject to restrictions as set forth in FAR ' 12.212 (Commercial Computer Software-Restricted Rights) and ' DFAR 227.7202 (Rights in Technical Data and Computer Software), ' as applicable. Manufacturer is Autodesk, Inc., 111 McInnis ' Parkway, San Rafael, California 94903. ' '============================================================================ Option Explicit On Error Resume Next dim bProdFound, b64bitOS, bRemovePlugins dim strInstallFolder, strProductName, strMainProductName dim strTitle, strMsg dim languageCode, languageAbbv dim heroProductPrefix, heroProductSuffix dim objShell dim intMsgRet dim x64products(4) dim x86products(4) const HKEY_CURRENT_USER = &H80000001 const HKEY_LOCAL_MACHINE = &H80000002 '============================================================================ ' set the GUID prefix and suffix for the main product being uninstalled heroProductPrefix = "{5783F2D7-9001" heroProductSuffix = "0060B0CE6BBA}" ' set the product language code and abbreviation ' English languageCode = "409" languageAbbv = "enu" '============================================================================ ' initialize the arrays with the GUIDs and names for all products we may need to uninstall ' AutoCAD 2011 English (x64) x64products(0) = heroProductPrefix & "-0" & languageCode & "-0102-" & heroProductSuffix ' AutoCAD 2011 English language pack (x64) x64products(1) = heroProductPrefix & "-0" & languageCode & "-1102-" & heroProductSuffix ' AutoCAD 2011 Subscription Advantage Pack (x64) x64products(2) = "{ADF5CB42-ACFD-41EF-0133-871E54505C1D}" ' AutoCAD WS plug-in for AutoCAD 2011 (x64) x64products(3) = "{BF780694-C47E-4122-0196-B89B22F3387C}" ' AutoCAD 2011 VBA Enabler (x64) x64products(4) = "{68519E09-4927-46AE-01E2-8D60D0CF41BC}" ' AutoCAD 2011 English (x86) x86products(0) = heroProductPrefix & "-0" & languageCode & "-0002-" & heroProductSuffix ' AutoCAD 2011 English language pack (x86) x86products(1) = heroProductPrefix & "-0" & languageCode & "-1002-" & heroProductSuffix ' AutoCAD 2011 Subscription Advantage Pack (x86) x86products(2) = "{42E572CC-6D4C-4A3E-B937-7594D36B2B44}" ' AutoCAD WS plug-in for AutoCAD 2011 (x86) x86products(3) = "{B96F1390-23DD-4002-B183-EF0560D784E9}" ' AutoCAD 2011 VBA Enabler (x86) x86products(4) = "{ED7DFC69-2B9A-4A1F-9F50-8AB89B688EBA}" 'initialize status variants bProdFound = False b64bitOS = False bRemovePlugins = False ' start by determing if we have a valid product installed Set objShell = CreateObject("Wscript.Shell") ' look for the x64 version first bProdFound = getProductInfo(x64products(0), False) b64bitOS = bProdFound ' if we didn't find it, look for the x86 version if bProdFound = False then bProdFound = getProductInfo(x86products(0), False) end if ' if we found an installed product, report it and get uninstall confirmation if bProdFound then strTitle = "AutoCAD 2011 Uninstall Script" strMainProductName = strProductName ' get approval to uninstall AutoCAD intMsgRet = uninstallACAD2011WarningMsg() ' if the user approved uninstall, proceed if intMsgRet = vbYes Then ' get approval to uninstall plugins intMsgRet = uninstallPluginsWarningMsg() ' if the user did not cancel the whole operation, proceed if intMsgRet <> vbCancel then if intMsgRet = vbYes Then bRemovePlugins = True end if if b64bitOS = True then uninstallProducts(x64products) else uninstallProducts(x86products) end if deleteProductFolders() deleteProductRegKeys() strMsg = strMainProductName & " Uninstall Complete." & Vbcrlf & Vbcrlf & _ "We recommend restarting your system to help ensure complete cleanup." intMsgRet = msgbox(strMsg, vbOkonly+VBExclamation, strTitle) end if end if Else strMsg = "No installation of AutoCAD 2011 was found." intMsgRet = msgbox(strMsg, vbOkonly+VBExclamation, strTitle) end if '============================================================================ ' uninstall each product code it finds '============================================================================ function uninstallProducts(aProductList) dim pos, retVal dim installer : Set installer = nothing dim strGUID, strModuleName Const msiUILevelBasic = 3 '/qb Const msiUILevelHideCancel = 32 '/! Const msiInstallStateAbsent = 2 On Error Resume Next Err.Clear Set installer = CreateObject("WindowsInstaller.Installer") installer.UILevel = msiUILevelBasic + msiUILevelHideCancel for pos = 0 to UBound(aProductList) strGUID = aProductList(pos) retVal = getProductInfo(strGUID, True) if retVal = True then strModuleName = strProductName if installer.productstate (strGUID) > 0 Then ' if the user did not approve removal of plug-ins, bail if pos > 1 and bRemovePlugins = False then Exit For end If 'WScript.Echo "Uninstalling " & strGUID & Vbcrlf & Vbcrlf & strModuleName installer.ConfigureProduct strGUID, 65535, msiInstallStateAbsent if Err.Number <> 0 then WScript.Echo "Error uninstalling " & strModuleName & Vbcrlf & Vbcrlf & _ "Error: " & Err.Number & " - " & Err.Description Err.Clear Else 'WScript.Echo "Uninstalled " & strModuleName end if end if end if next set installer = Nothing end function '============================================================================ ' delete folders '============================================================================ function deleteProductFolders() dim pos dim loopCtr dim sUsrProfile dim productFolders(6) dim objFileSys On Error Resume Next Set objFileSys = CreateObject("Scripting.FileSystemObject") 'Expand Environment sUsrProfile = objShell.ExpandEnvironmentStrings("%UserProfile%") ' actual installation location as retrieved from registry productFolders(0) = strInstallFolder ' windows vista/win7 related AutoCAD program paths productFolders(1) = "C:\ProgramData\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv productFolders(2) = sUsrProfile & "\AppData\Local\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv productFolders(3) = sUsrProfile & "\AppData\Roaming\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv ' windows XP related AutoCAD program paths productFolders(4) = sUsrProfile & "\Application Data\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv productFolders(5) = sUsrProfile & "\Local Settings\Application Data\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv productFolders(6) = "C:\Documents and Settings\All Users\Application Data\Autodesk\AutoCAD 2011\R18.1\" & languageAbbv Err.Clear for pos = 0 to UBound(productFolders) loopCtr = 0 ' delete the folder within a 30-second loop to account for system lock issues do While objFileSys.FolderExists(productFolders(pos)) And loopCtr < 6 objFileSys.DeleteFolder productFolders(pos), True if Err.Number <> 0 then WScript.Echo "Folder not deleted: " & productFolders(pos) & Vbcrlf & Vbcrlf & _ "Error: " & Err.Number & " - " & Err.Description Err.Clear WScript.Sleep 5000 ' sleep 5 seconds loopCtr = loopCtr + 1 Else 'WScript.Echo "Folder deleted: " & productFolders(pos) end if Loop next Set objFileSys = Nothing end function '============================================================================ ' delete registry keys for the specific installed product and language '============================================================================ function deleteProductRegKeys() dim pos dim HKCURegKeys(3) dim HKLMRegKeys(3) HKCURegKeys(0) = "Software\Autodesk\AutoCAD\R18.1\ACAD-9001:" & languageCode HKCURegKeys(1) = "Software\Autodesk\AutoCAD\R18.1\AutoCAD 2011 Subscription Advantage Pack" HKCURegKeys(2) = "Software\Autodesk\AutoCAD\R18.1\AutoCAD 2011 VBA Enabler" HKCURegKeys(3) = "Software\Autodesk\AutoCAD\R18.1\AutoCAD WS plug-in for AutoCAD 2011" HKLMRegKeys(0) = "Software\Autodesk\AutoCAD\R18.1\ACAD-9001:" & languageCode ' the following modules are English-only so the language code is hard-coded HKLMRegKeys(1) = "Software\Autodesk\AutoCAD 2011 Subscription Advantage Pack:409" HKLMRegKeys(2) = "Software\Autodesk\AutoCAD 2011 VBA Enabler:409" HKLMRegKeys(3) = "Software\Autodesk\AutoCAD WS plug-in for AutoCAD 2011:409" ' delete the AutoCAD product reg keys deleteRegKey HKEY_CURRENT_USER, HKCURegKeys(0) deleteRegKey HKEY_LOCAL_MACHINE, HKLMRegKeys(0) ' delete the AutoCAD EULA reg key deleteRegKey HKEY_LOCAL_MACHINE, "Software\Autodesk\AutoCAD 2011 - English" if bRemovePlugins then for pos = 1 to UBound(HKCURegKeys) deleteRegKey HKEY_CURRENT_USER, HKCURegKeys(pos) deleteRegKey HKEY_LOCAL_MACHINE, HKLMRegKeys(pos) next end if end function '============================================================================ ' delete registry key '============================================================================ sub deleteRegKey(rootKey, delKey) dim strComputer, strRootKey dim objRegistry : set objRegistry = Nothing strComputer = "." On Error Resume Next Err.Clear if rootKey = HKEY_CURRENT_USER then strRootKey = "HKCU\" else strRootKey = "HKLM\" end if Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") if regKeyFound(strRootKey & delKey & "\") Then objRegistry.DeleteKey rootKey, delKey if Err.Number <> 0 then WScript.Echo "DeleteKey failed: " & delKey & Vbcrlf & Vbcrlf & _ "Error: " & Err.Number & " - " & Err.Description Err.Clear else 'Wscript.Echo "Deleted: " & strRootKey & delKey End If Else 'WScript.Echo "Key not found: " & strRootKey & delKey End If Set objRegistry = Nothing end sub '============================================================================ ' search for installed product and get the installation folder and name '============================================================================ function getProductInfo(prodCode, bNameOnly) dim strKeyPath, strValueName, strComputer dim objRegistry : set objRegistry = Nothing strComputer = "." Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & prodCode ' determine if the product is installed if regKeyFound("HKLM\" & strKeyPath & "\") Then ' Get the name of the product being uninstalled strValueName = "DisplayName" objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strProductName if bNameOnly = False then strKeyPath = "SOFTWARE\Autodesk\AutoCAD\R18.1\ACAD-9001:" & languageCode if regKeyFound("HKLM\" & strKeyPath & "\") Then ' Get the actual installation location before uninstalling strValueName = "AcadLocation" objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strInstallFolder End If end if getProductInfo = True Else getProductInfo = False End If Set objRegistry = Nothing end function '============================================================================ ' returns true if a registry key exists '============================================================================ function regKeyFound(regkey) Dim retVal On Error Resume Next Err.Clear retVal = objShell.RegRead(regkey) if Err.Number <> 0 then 'WScript.Echo "Error reading key: " & regkey & Vbcrlf & Vbcrlf & _ ' "Error: " & hex(Err.Number) & " - " & Err.Description Err.Clear regKeyFound = False else regKeyFound = True End If end function '============================================================================ ' display the initial warning message and get OK to continue '============================================================================ function uninstallACAD2011WarningMsg() dim strMsg strMsg = "WARNING!" & Vbcrlf & Vbcrlf & _ strMainProductName & " is currently installed at" & Vbcrlf & _ strInstallFolder & Vbcrlf & Vbcrlf & _ "This script will remove " & strMainProductName & " and related folders and registry keys from your computer." & Vbcrlf & Vbcrlf & _ "This script should be run an as Administrator and we strongly recommend backing up any custom files before proceeding." & Vbcrlf & Vbcrlf & _ "Do you want to continue?" uninstallACAD2011WarningMsg = msgbox(strMsg, vbYesNo+VBExclamation, strTitle) end function '============================================================================ ' get the OK to uninstall plug-ins '============================================================================ function uninstallPluginsWarningMsg() dim strMsg strMsg = "This script can also remove the VBA Enabler," & Vbcrlf & _ "Subscription Advantage Pack, and WS Plug-in." & Vbcrlf & Vbcrlf & _ "These modules should NOT be uninstalled if they" & Vbcrlf & _ "are shared by another AutoCAD installation." & Vbcrlf & Vbcrlf & _ "Do you want to uninstall these modules?" uninstallPluginsWarningMsg = msgbox(strMsg, vbYesNoCancel+VBExclamation, strTitle) end function

Tuesday, May 11, 2010

Autodesk possible cross-product scripting language/IDE

This post has best before date of May 30th, 2010.

Autodesk is researching candidates for a possible cross-product scripting language/IDE. What is your preferred language?

  • Javascript/ECMAScript
  • Python
  • Ruby
  • Lua
  • VBA/VBScript

If you want to make your voice heard on this question and others take the survey for the product you work with.

AutoCAD® Civil 3D®
AutoCAD® Map 3D®
Autodesk Inventor®
Autodesk Navisworks®

Via Through the Interface: API wishlist surveys for Autodesk products

Wednesday, May 20, 2009

AdskHwCertificationDatabase.xml location

Certified Hardware XML Database Update as well as this Update Graphics Card Driver page are having details on how to download the latest Hardware Certification Database file as well as how to install it.

What it is missing is to tell where the AdskHwCertificationDatabase.xml file is located on AutoCAD 2009 and 2010 as it only describes how to update it from within AutoCAD.

This can be useful to know if AutoCAD for some reason cannot install it as it should or if you want to distribute the newest file to multiple users in your network.

Here is one “Performance Tuner Update” error using 3DCONFIG and Check for Updates that can show up: “Performance Tuner failed to update. Please check your network connection and make sure you have write permission to the file.

The location used to be in the DRV folder where AutoCAD is installed like:
c:\program files\AutoCAD 2008\DRV

So where can AdskHwCertificationDatabase.xml be found?

Here are some locations where this file can be found in newer AutoCAD versions:
<ROOT>\Autodesk\AutoCAD 2009\R17.2\enu\PTXML
<ROOT>\Autodesk\AutoCAD 2010\R18.0\enu\PTXML
<ROOT>\Autodesk\ACA 2010\enu\PTXML

<ROOT> to be replaced with either of the following in Windows XP:
C:\Documents and Settings\All Users\Application Data
%ALLUSERSPROFILE%\Application Data

<ROOT> to be replaced with either of the following in Windows Vista and Windows 7:

Now you can use any of your favorite scripting method like KiXtart, VBScript, plain old BAT or CMD or why not PowerShell and have it run as a login script. You can even do it from a single location if you have enough permissions. See this example.

For the Graphics Hardware List see

Thursday, April 9, 2009

Scripting on remote computers

Here is a great blog post by Dave: Scripting with Glue and Tape. It shows how you for example can execute batch script on a list of remote computers.

Wednesday, August 20, 2008

AutoCAD Architecture PSD showing the drawing name

There was a question in the AutoCAD Architecture discussion group.

“How can i get dwgname of open drawing  in this drawing in  property set per vbscript code?”

Here is how it can be done. I use ACA 2009 but it should work with older versions too. Formula Property Definition below:

On Error Resume Next
Set app = GetObject(, "AutoCAD.Application")

If the full path and name needs to be use just change ActiveDocument.Name to ActiveDocument.FullName.

Thursday, March 27, 2008

DWG TrueView 2009 includes measuring ability

DWG TrueView 2009 is Autodesk's free viewer for DWG files and is found here:

DWG TrueView 2009

The big news are:

  • Measure objects with these new inquiry commands: Distance, Area, List, Locate Point, Region/Mass properties, and Object Snaps.
  • Enhanced UI with the addition of Ribbon Navigation
  • Measure objects with these new commands: Distance, Area, List, Locate Point, Region/Mass properties, and Object Snaps
  • Navigate drawings in 2D and 3D with SteeringWheel
  • Enhanced 3D view selection with ViewCube
  • Restore views and play new "animated" views with ShowMotion


It is quite a big install on almost 200 MB for the 32-bit version and bit more for the 64-bit version.

DWG TrueConvert is available from within the program and can convert from and to different versions of the DWG format.

DWG TrueView 2009 can be installed side by side with for example AutoCAD 2009.

Here is a tip I maybe should keep quiet about as I might sell fewer licenses of SmartPurger because of it. You can with some limitations batch purge drawings using DWG Convert as there is an option to purge included and even "Check and Fix Errors" (When active, drawings are checked for the presence of errors. Drawings are automatically recovered if errors are found).

Silent installation of DWG TrueView 2009 could be done with a VBScript like this:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
runstring="msiexec /I ""\\DWGTrueViewx86InstallImage\DWGVIEWR.msi"" /qb! " & _
"INSTALLDIR=""C:\Program Files\DWG TrueView 2009"" " & _
WshShell.Run runstring,1,true
msgbox "Ready"

This previous post describes more details on silent installation.

For more important details like how to handle drawings created with a vertical like AutoCAD Architecture or 3:rd party applications that creates custom objects see the FAQ.

Wednesday, October 17, 2007

HKEY_CLASSES_ROOT (HKCR) key description

imageHere is a tip. Avoid writing, deleting or merging (like .REG files or using regedit.exe) to HKEY_CLASSES_ROOT.


Basically because HKCR is a merged view based on HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes and it can be confusing as to if this will work for the current user, a new user, the administrator user or so.

The registry system uses the following rules to merge information from the two sources:

  • The merged view includes all subkeys of the HKEY_CURRENT_USER\Software\Classes key.
  • The merged view includes all immediate subkeys of the HKEY_LOCAL_MACHINE\Software\Classes key that do not duplicate the subkeys of HKEY_CURRENT_USER\Software\Classes.
  • Below is a list of subkeys that are found in both HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes. The immediate subkeys of these keys from the HKEY_LOCAL_MACHINE tree are included in the merged view only if they are not duplicates of immediate subkeys from the HKEY_CURRENT_USER tree. The merged view does not include the HKEY_LOCAL_MACHINE contents of duplicate subkeys.

The following subkeys are found in both HKEY_LOCAL_MACHINE\Software\Classes and HKEY_CURRENT_USER\Software\Classes. From the HKEY_LOCAL_MACHINE tree, the immediate subkeys of these keys are included in the merged view only if they are not duplicates of immediate subkeys from the HKEY_CURRENT_USER tree. The merged view does not include the HKEY_LOCAL_MACHINE contents of duplicate subkeys.

Component Categories
Mime\Database\Content Type

The HKCR key contains file extension associations and COM class registration information such as ProgIDs, CLSIDs, and IIDs.

More is found in this MSDN document.

Wednesday, October 3, 2007

Review of Dynamsoft software version control

imageI've started to try Dynamsoft SourceAnywhere Hosted and will post more as I continue using it.

I use it together with Visual Studio 2005 but also with other file formats like AutoLISP (Visual LISP) files. There is no limitation on what type of files that can be hosted.

It was very straight forward and intuitive to start using SourceAnywhere Hosted. So far so good.


If you too want to try it they have a Free Hosting Plan for up to to 3 users and 15M storage space.


Disclaimer. I was offered for free a plan of Dynamsoft SourceAnywhere Hosted that receives the same service as the paid account.

Friday, August 17, 2007

Start a Windows application within AutoCAD

One way is achieved by the AutoLISP function startapp. Notice that the control of what is started is not in the hand of AutoCAD. So if you have an AutoLISP program the code will just continue executing.

Here is an example how it can be used to open with Notepad the acad.pgp file that AutoCAD uses. If you do edit the acad.pgp file you need to run the ReInit command and select the PGP file check box so the changes will be used by AutoCAD. Or if you want to use AutoLISP: (setvar "re-init" 16)

Command: (startapp "notepad" (findfile "acad.pgp"))

33 is the return value. As long as not nil is returned the function is successful.

Notice that if one of the arguments contain spaces you need to use double quotes like this sample: (startapp "notepad.exe" "\"file with spaces in the name.txt\"")

If you want to launch Windows Explorer here is one way to open the folder of the current drawing: (startapp (strcat "explorer /e," (getvar "dwgprefix")))

To open a PDF file in the default PDF reader.
(startapp "explorer.exe" "C:\\PDFs\\test.pdf")

If you want to open a PDF file in Adobe Reader 8.0 at a specific page this can be used.(startapp "\"C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\AcroRd32.exe\"" "\"/A page=5 C:\\Program Files\\Adobe\\Reader 8.0\\Reader\\plug_ins\\Annotations\\Stamps\\ENU\\StandardBusiness.pdf\"")

If you want to open a DWF file in Autodesk Design Review here is how:(startapp "\"C:\\Program Files\\Autodesk\\Autodesk Design Review\\DesignReview.exe\"" "\"C:\\Program Files\\Autodesk\\Autodesk Design Review\\Tutorial\\IRD Addition Autodesk Design Review Sample.dwf\"")

And another one if you want to open a DWF in your favorite web browser:
(command "_browser" "")

To run a VBScript this can be used:
(startapp "wscript" "c:/MyCoolScript.vbs")

There is also the AutoCAD command SHELL.

With SHELL, you can execute operating system (OS) commands while remaining in this program. When SHELL prompts you for an OS command, you can enter most valid commands for your OS. When the command has been executed, SHELL returns you to the Command prompt. You can also call the SHELL command with AutoLISP like this: (command "_shell" "dir *.dwg /p")

Another alternative is if you have DOSLib. In that case you can use the function dos_execute (Runs an external program), dos_exewait (Runs a program and waits for completion) or dos_shellexe (Opens or prints a program or file). You can with these also control how the newly opened window is to be displayed.

I think you pretty much get the idea. If you have any sample you want to share please add a comment below.

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner