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

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: http://www.autodesk.com/dwgtrueview

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

Inquiry

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"" " & _
"ACAD_SILENT_LICENSE=YES"
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.

Why?

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.

*
*\shellex
*\shellex\ContextMenuHandlers
*\shellex\PropertySheetHandlers
AppID
ClsID
Component Categories
Drive
Drive\shellex
Drive\shellex\ContextMenuHandlers
Drive\shellex\PropertySheetHandlers
FileType
Folder
Folder\shellex
Folder\shellex\ColumnHandler
Folder\shellex\ContextMenuHandlers
Folder\shellex\ExtShellFolderViews
Folder\shellex\PropertySheetHandlers
Installer\Components
Installer\Features
Installer\Products
Interface
Mime
Mime\Database
Mime\Database\Charset
Mime\Database\Codepage
Mime\Database\Content Type
Typelib

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 03, 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.

dynamsoft

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

image

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

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")))

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" "http://freewheel.autodesk.com/dwf.aspx?path=http://freewheel.autodesk.com/sample/Hotel5.dwf&sec=1")

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.

Friday, July 13, 2007

Uninstall AutoCAD 2008 silently

If you as are managing installations on many workstations you probably at some point want to uninstall software's easily. This is one way to do it. You can often find the uninstall string in the registry.

Uninstall AutoCAD 2008

  • HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.1\ACAD-6001:409\ProductCode
    The value can be something like this:
    {5783F2D7-6001-0409-0002-0060B0CE6BBA}

Uninstall AutCAD Architecture 2008

    HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.1\ACAD-6004:409\ProductCode
    The value can be something like this:
    {5783F2D7-6004-0409-0002-0060B0CE6BBA}

Uninstall Adobe Acrobat 8 Professional

  • HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Adobe Acrobat\8.0\Installer\ENU_GUID
    The value can be something like this:
    {AC76BA86-1033-0000-7760-000000000003}

Uninstall Acrobat Reader 8

  • HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Acrobat Reader\8.0\Installer\ENU_GUID
    The value can be something like this:
    {AC76BA86-7AD7-1033-7B44-A81000000003}


If you are using VBScript you can read the registry using WshShell.RegRead

Below is a sample code showing how it can be done. Save the text in Notepad with the file extension VBS.

on error resume next
Set WshShell = CreateObject("WScript.Shell")
uninstallstring=WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\R17.1\ACAD-6001:409\ProductCode")
WshShell.Run "msiexec /x " & uninstallstring & " /q",1,true

Thursday, January 25, 2007

ADT Window Style Type in a PSD

I noticed a question on the Architectural Desktop discussion group and wanted to share the solution here. The Window Type for a windows style is not available as an automatic property. So a bit of VBScript is needed.

Create a PSD (Property Set Definition) that applies to Windows styles and add the automatic property Handle. Then add the formula below. Notice that [Handle] in the formula must be selected from the "Insert Property Definitions" list.

In the code AecX.AecArchBaseApplication.5.0 refers to ADT 2007.

For other versions of ADT change it.

ADT 2004 - AecX.AecArchBaseApplication.4
ADT 2005 - AecX.AecArchBaseApplication.4.5
ADT 2006 - AecX.AecArchBaseApplication.4.7
ADT 2007 - AecX.AecArchBaseApplication.5.0
ACA 2008 - AecX.AecArchBaseApplication.5.5

On Error Resume Next Set app = GetObject(, "AutoCAD.Application") Set AecArchBaseApplication = app.GetInterfaceObject("AecX.AecArchBaseApplication.5.0") Set doc = AecArchBaseApplication.ActiveDocument Set WindowStyles = doc.WindowStyles Set WindowObject = doc.HandleToObject("[Handle]") Set WindowStyle = WindowStyles.Item(WindowObject.StyleName) Select Case WindowStyle.Type Case 0 RESULT = "Custom" Case 1 RESULT = "Picture" Case 2 RESULT = "Single Hung" Case 3 RESULT = "Double Hung" Case 4 RESULT = "Awning - Transom" Case 5 RESULT = "Double Casement" Case 6 RESULT = "Glider" Case 7 RESULT = "Hopper - Transom" Case 8 RESULT = "Pass Through" Case 9 RESULT = "Single Casement" Case 10 RESULT = "Single Hopper" Case 11 RESULT = "Single Awning" Case 12 RESULT = "Vertical Pivot" Case 13 RESULT = "Horizontal Pivot" Case 14 RESULT = "Uneven Single Hung" Case 15 RESULT = "Uneven Double Hung" End Select

Sunday, December 17, 2006

Introduction to Windows PowerShell

Are you using VBScript, CMD or BAT? Are you using the old Command line using cmd.exe? Then Windows PowerShell is worth looking at. Windows PowerShell™ is a new Windows command-line shell.

Take a look at the VBScript to Windows PowerShell Conversion Guide. See Windows PowerShell Team blog and download from the homepage for Windows PowerShell.

You can run Windows command-line programs and start Windows graphic programs in Windows PowerShell. In Windows PowerShell, script files have a .ps1 file name extension.

Support for Tab-Completion. Start with for example get- and press tab several times and find cndket's like Get-Acl, Get-Alias, etc.

Windows PowerShell is built on top of the .NET common language runtime (CLR) and the .NET Framework, and accepts and returns .NET objects and you work with methods and properties.

Windows PowerShell has syntax features and keywords that are very similar to those used in the C# programming language.

A cmdlet (pronounced "command-let") is a single-feature command that manipulates objects in Windows PowerShell. You can recognize cmdlets by their name format -- a verb and noun separated by a dash (-), such as Get-Help, Get-Process, and Start-Service.

Windows Management Instrumentation (WMI) is supported with the cmdlet for accessing WMI objects, Get-WmiObject and is one of the most powerful ones.

You can reference COM objects like WScript.Shell.
$WshShell = New-Object -ComObject WScript.Shell

You can use the Win32_Product class to install Windows Installer packages, remotely or locally.

In addition to the familiar file system drives, such as C: and D:, Windows PowerShell includes drives that represent the HKEY_LOCAL_MACHINE (HKLM:) and HKEY_CURRENT_USER (HKCU:) registry hives.

Technorati tags:

Wednesday, August 09, 2006

Tip on a bunch of free Microsoft software's you maybe didn't know about.

Here are some free Microsoft software's that you maybe didn't know about and that you too might like or see a need to use. I'll add them here as a reminder for myself anyway. If you have any free Microsoft software you would like to add please make a comment.

Microsoft PowerToys for Windows XP including SyncToy (copy, move, and synchronize different directories), ClearType Tuner (tune the ClearType settings to fit your eyes the best), Open Command Window Here, Tweak UI (gives you access to system settings that are not exposed in the Windows XP default user interface, including mouse settings, Explorer settings, taskbar settings, and more), Power Calculator (you can graph and evaluate functions), etc.

Windows Defender (Beta 2) is a free program that helps you stay productive by protecting your computer against pop-ups, slow performance and security threats caused by spyware and other potentially unwanted software.

FolderShare allows you to create a private peer-to-peer network that will help you to synchronize files across multiple devices and access or share files with colleagues and friends. Share files up to 2 GB in size. No limits on quantity or size or type of files transferred.

Microsoft Time Zone conveniently runs in the system tray and allows you to easily view the date and time in various locations around the world. You can also quickly and easily add your own personal locations to customize Microsoft Time Zone the way you want.

Calculator Plus a better Calculator that also performs many different types of conversions.

Virtual CD-ROM Control Panel for Windows XP allows image files (ISO) to be mounted virtually as CD-ROM/DVD-ROM devices. Useful if you don't want to write the image to a CD/DVD-R using software's with ISO image file support. Windows Server 2003 Resource Kit includes the DVDBURN.EXE command line tool useful for writing ISO files to CD-R or DVD-R.

Tweakomatic utility that writes Windows Management Instrumentation (WMI) scripts.

Windows Deployment and Resource Kits including among many other useful tools Robocopy.exe - Robust File Copy Utility

Virtual PC to run multiple operating systems at the same time on the same physical computer. Switch between virtual machines with the click of a button.

Agent components for animated characters that can be useful in your applications. With interactive personalities in the form of animated characters you can make them move, talk, listen and react and more. I've used it for guiding users through lengthy installations using VBScript for applications like Autodesk AutoCAD and ADT.

GroupBar is lightweight desktop tool that offers enhanced window management capabilities in a Windows taskbar-like setting.

Scalable Fabric  is a task management system for the Windows desktop. Download here.

User State Migration is used to migrate user data and application configurations for a user's current client computer to a new client computer.

Windows Media Encoder including Windows Media Encoder Studio Edition and Windows Media Encoder 9 Series. Use it to capture, compress and encode audio and video content.

And much more...

Update: Road to Know Where! has the Ultimate List of Free Windows Software from Microsoft and the Ultimate List of Free Office Software from Microsoft

tags: ,

Sunday, August 06, 2006

Linus Torvald about Visual Basic and me about Sinclair ZX81

I recently learned from "Stiff asks, great programmers answer" that Peter Norvig Director of Research at Google has Lisp as one of his favorite languages. Linus Torvalds (behind Linux) also comments how "Visual Basic" did more for programming than "Object-Oriented Languages" did.

The questions he asked where the following and for the fun of it and for your curiosity I added my answers too.

- How did you learn programming? Were any schools of any use? Or maybe you didn’t even bother with ending any schools :) ?

Sinclair ZX81I learned programming using a Sinclair ZX81 in the early 80:ies. I got an extra 16KB RAM pack (the base system only had 1024 bytes RAM). I used the black and white TV as screen as well as an old tape recorder to save my programs on magnetic audio tapes. The language used was ZX Assembler and BASIC and I had a lot of fun creating games, logical, math and graphic programs.

10 PRINT "Hello world!"

Then I used computers in school as much as I could. From computers like ABC80 and ABC800 to Compis (based on the Intel 80186 CPU and with CP/M-86 as the operating system in ROM). I used Compis from 1986-1988 and did my special school work programming in Comal and Pascal. I reverse engineered a database format and provided a user interface to work with the demographic data in it.

- What do you think is the most important skill every programmer should posses?

Be open and flexible to use the tool or method that is best for the specific case. That's anyway one important skill even though I don't think there is only one that is most important.

- Do you think mathematics and/or physics are an important skill for a programmer? Why?

It all depends but if you learn math and physics it might help. I have done several programs that has required both math and/or physic skills.

- What do you think will be the next big thing in computer programming? X-oriented programming, y language, quantum computers, what?

I have no idea.

- If you had three months to learn one relatively new technology, which one would You choose?

Web 2.0 and the like.

- What do you think makes some programmers 10 or 100 times more productive than others?

Concentration and focus does a lot. Some are more "into" programming than others, love programming, logic thinking, problem solvers.

- What are your favorite tools (operating system, programming/scripting language, text editor, version control system, shell, database engine, other tools you can’t live without) and why do you like them more than others?

I use whatever needed to do the job done and sometimes I use the tools that I use the most. Right now it's Windows OS, Visual Studio 2005 and VB.NET, VBScript, AutoLISP, SQL Server and Access. One language that I don't use now but I loved to use was Modula-2. Lisp is really a favorite language.

- What is your favorite book related to computer programming?

Don't have any but one good one is Applying Domain-Driven Design and Patterns by Jimmy Nilsson with a lot of .NET focus.

- What is Your favorite book NOT related to computer programming?

Being a CAD related blog I appreciated reading The Autodesk File. "The history of Autodesk and AutoCAD told through contemporary documents, edited and annotated by Autodesk founder John Walker."

- What are your favorite music bands/performers/compositors?

Level42 / Bryan Adams / Benny Andersson just to mention some that have made a lot of great music.

[Via Coding Horror | stifflog²]

tags: , ,

Thursday, July 27, 2006

Autodesk DWF Viewer 7.0 deployment tips & trix

Using VBScript (file with VBS extension) Autodesk DWF Viewer 7.0 can be installed and configured unattended or silently. One new thing with version 7.0 is that an MSI file that can be downloaded from www.autodesk.com/dwfviewer. Below are some tips & tricks that you can get ideas from.

By default, DWF Viewer checks for its latest version on the Autodesk Web site (Help > Check for Updates...). You can configure DWF Viewer to check for an update from another location, such as your company's Web site server, allowing you to control which version is available to your users. See the help file on Programming and Administration>Check for Updates from a Non-Autodesk Server.

To install:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
' Progress bar without cancel button
WshShell.Run """\\server\DWF\7.0\DwfViewerSetup.msi"" /qb!",1,true


This could be done as a post installation:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' Delete the link from the start menu
key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\" & _
  "CurrentVersion\Explorer\Shell Folders\"
path=WshShell.RegRead(key & "Common Programs") & "\Autodesk"
fso.DeleteFile path & "\Autodesk DWF Viewer.lnk",True

' Delete the folder from the start menu if it's empty
if FolderEmpty(path) then fso.DeleteFolder path, True

' Do not show dialog box asking for update if a newer version is available
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\DoNotShowAgain"
WshShell.RegWrite key, 1, "REG_DWORD"

' Do not check for a new version when starting DWF Viewer
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\InitialCheck"
WshShell.RegWrite key, 1, "REG_DWORD"

' Do not check that often (number in days)
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\CheckInterval"
WshShell.RegWrite key, 1000, "REG_DWORD"

' Make sure that if the user cannot update from the Help menu by pointing to an invalid location
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\URL"
WshShell.RegWrite key, "C:\", "REG_SZ"

' Use single click to follow hyperlinks
key = "HKEY_CURRENT_USER\Software\Autodesk\DWF Common\" & _
  "Preferences\User Interface\Single Click Hyperlink"
WshShell.RegWrite key, 1, "REG_DWORD"

' Suppress Getting started Page
key = "HKEY_CURRENT_USER\Software\Autodesk\DWF Common\" & _
  "Preferences\User Interface\Suppress Startup Page"
WshShell.RegWrite key, 1, "REG_DWORD"

Function FolderEmpty (path1)
  Set oFolder = fso.GetFolder(path1)
  Set oFiles = oFolder.Files
  flag = true
  For Each i in oFiles
    flag = false
  Next
  FolderEmpty = flag
End function


To uninstall:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\" & _
  "Uninstall\Autodesk DWF Viewer\UninstallString"
UninstallString=WshShell.RegRead(key)
if UninstallString<>"" then WshShell.Run "msiexec /x {9A346205-EA92-4406-B1AB-50379DA3F057} /qb!",1,true
                                                       

It is also possible to sidable some menu items in the Viewer by editing this file:
C:\Program Files\Autodesk\Autodesk DWF Viewer\EComposite\menubar_exe.htm

Here are some examples:

helpRegisterMenu.disabled = false; can be changed to helpRegisterMenu.disabled = true;

helpUpdateMenu.disabled = false; can be changed to helpUpdateMenu.disabled = true;

Friday, March 03, 2006

How to install a printer from a DWF

I have though about sharing this tip about "Printer Connector" a long time. I've got some emails from those wondering how it could be done after Shaan Hurley, Autodesk posted about a solution I made a few years ago at the company I work for. Now I got reminded again reading about Internal Facilities Management application by Scott Sheppard, Autodesk. I assisted Brian Mathews and Brian Pene at their class at Autodesk University 2005 in Florida and I really recommend you to take a look at the available class materials you can find on Scott's blog. Actually Brian was one of those wondering how I had solved installing the printers from a DWF hyperlink. Nice to see that it's used at Autodesk too. Now to the solution that is really simple but useful.

Start with a DWG drawing of the facility and add a block that represents a printer or plotter. Add a hyperlink on the block that links to a html file on a location available for all users. Use the name of the printer and maybe size and type as description. The content of the html file is here. Just change the server name and the printer name in the code. Now Plot or Publish the drawing to DWF. If you have several levels and buildings you can create a main html page that links to these DWF files. The DWF files can also be embedded into a html page and add some simple instructions that they should click on a printer etc.

<html>
<head>
</head>
<p><font face="Verdana">Printer connection...</font></p>
<SCRIPT LANGUAGE="VBScript">
<!--
on error resume next
Set WshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\SERVERNAME\PRINTERNAME"
msg="Do you want " & PrinterPath & " to be Default printer?"
answ=msgbox(msg,vbYesNoCancel,"Add Printer")
If answ=vbYes then
  WshNetwork.AddWindowsPrinterConnection PrinterPath
  WshNetwork.SetDefaultPrinter PrinterPath
elseif answ=vbNo then
  WshNetwork.AddWindowsPrinterConnection PrinterPath
end if
history.back()
-->
</SCRIPT>
</html>
See this html code or check in the DWF Viewer Help.
<script language="vbscript">
<!--
on error resume next
if not IsObject(CreateObject("AdView.AdViewer")) then msgbox "You need the DWF Viewer!" & vbNewLine & vbNewLine & "Please contact the IT department."
function ShowPrinters
EView.Viewer.HighlightLinks = not EView.Viewer.HighlightLinks
end function
-->
</script>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Printer Connector</title>
<style type="text/css">
a:link {color: #FFFFFF}
a:visited {color: #FFFFFF}
a:hover {color: #FF0000}
a:active {color: #FFFFFF}
</style>
</head>

<body bgcolor="#4083A8" topmargin="0">

<OBJECT
id=Eview
codeBase="file:///server/dwfviewer/installer/DwfViewerSetup.cab"
classid=clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF
width=100%
height=92% border="2" vspace="4">
<param name="_cx" value="38788">
<param name="_cy" value="25056">
<param name="BackColor" value="7895160">
<param name="EmbedDoc" value="0">
<param name="Src" value="Printers.dwf?NotifyMissingFonts = false">
<param name="ViewerParams" value="?NotifyMissingFonts = false">
</OBJECT>

<script language="vbscript">
<!--
; If multipage DWF's are used navigate to the page named "Level 8"
EView.Viewer.Page = "Level 8"
-->
</script>

<font face="Verdana" color="#FFFFFF" size="2">
<i>Click on the
<a title="Flash the printers" href="vbscript:ShowPrinters">printer</a> you want to have installed.
</i></font><br>
<font face="Verdana" size="1"><font color="#FFFFFF">Send mail to
<a href="mailto:HelpDesk%20IT?subject=Printer Connector">HelpDesk IT</a> or
the </font>
<a href="mailto:info@jtbworld.com?subject=Printer Connector">
Author</a><font color="#FFFFFF">
with questions or comments about Printer Connector.</font></font>
</body>

</html>

I recommend that you activate usage of single click to follow hyperlinks or include instructions to hold down CTRL + Click.

I hope you get the idea. Feel free to use it, have fun and impress on your management and users and IT. Feel free to contact me if you got any questions or post a comment.

Thursday, January 19, 2006

Find the path to My Documents using VBScript

Set WshShell = Wscript.CreateObject("Wscript.Shell")
path=WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal")
Observe that it's Personal that keeps the path to My Documents. This works if the path is below C:\Documents and Settings\ or redirected to a server location like \\server\home$\Jimmy.Bergmark PS. to show code like above I've used HTML code like this. It's useful when the rows are long. Setting the height and width so it fits for the purpose.
<pre style="margin:0px; padding:6px; border:1px #666666 solid; width:600px; 
height:70px; overflow:auto"></pre>

Saturday, January 07, 2006

Autodesk DWF Viewer deployment tips & trix

Using VBScript (file with VBS extension) Autodesk DWF Viewer can be installed and configured unattended or silently. Below are some tips & trix that you can get ideas from. By default, DWF Viewer checks for its latest version on the Autodesk Web site (Help > Check for Updates...). You can configure DWF Viewer to check for an update from another location, such as your company's Web site server, allowing you to control which version is available to your users. See the help file on Programming and Administration>Check for Updates from a Non-Autodesk Server.

To install:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
' /q2 is install without progress meter
' /q is install with progress meter
WshShell.Run """//server/DWF/6.5/DwfViewerSetup.exe"" /q",1,true


Here is something that could be done as a post installation:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' Delete the link from the start menu
key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\" & _
  "CurrentVersion\Explorer\Shell Folders\"
path=WshShell.RegRead(key & "Common Programs") & "\Autodesk"
fso.DeleteFile path & "\Autodesk DWF Viewer.lnk",True

' Delete the folder from the start menu if it's empty
if FolderEmpty(path) then fso.DeleteFolder path, True

' Do not check for a new version when starting DWF Viewer
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\InitialCheck"
WshShell.RegWrite key, 1, "REG_DWORD"

' Do not check that often
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\CheckInterval"
WshShell.RegWrite key, 1000, "REG_DWORD"

' Make sure that if the user cannot update from the Help menu
key = "HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\" & _
  "DWF Viewer\Settings\AutoUpdate\URL"
WshShell.RegWrite key, "C:\", "REG_SZ"

' Use single click to follow hyperlinks
key = "HKEY_CURRENT_USER\Software\Autodesk\DWF Common\" & _
  "Preferences\User Interface\Single Click Hyperlink"
WshShell.RegWrite key, 1, "REG_DWORD"

' Suppress Getting started Page
key = "HKEY_CURRENT_USER\Software\Autodesk\DWF Common\" & _
  "Preferences\User Interface\Suppress Startup Page"
WshShell.RegWrite key, 1, "REG_DWORD"

Function FolderEmpty (path1)
  Set oFolder = fso.GetFolder(path1)
  Set oFiles = oFolder.Files
  flag = true
  For Each i in oFiles
    flag = false
  Next
  FolderEmpty = flag
End function


To uninstall:
on error resume next
Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
key="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\" & _
  "Uninstall\Autodesk DWF Viewer\UninstallString"
UninstallString=WshShell.RegRead(key)
if UninstallString<>"" then WshShell.Run UninstallString & " /q",1,true

Tuesday, November 01, 2005

Silent installation of Autodesk DWG TrueView

To install Autodesk DWG TrueView with a click on a button create a VBScript. Then you can just send a link to the file to the users or deploy it with other means. Download the free viewer and extract the zip file to a server location. Open Notepad and enter the following code and save the file with the vbs file extension.

on error resume next
Set WshShell = CreateObject("WScript.Shell")
runstring="msiexec /I ""\\server\SetupDWGTrueView2\DWGV.msi"" /qb! " & _
"INSTALLDIR=""C:\Program Files\Autodesk\DWG TrueView"" " & _
"ACAD_SILENT_LICENSE=YES"
WshShell.Run runstring,1,true
msgbox "Ready"

You have to correct the path to the msi file.
For complete options to use with msiexec command, see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/msiexec.mspx.
Using VBScript it's also possible to prepare a profile in DWG TrueView. Make the changes in Tools>Options. Locate HKEY_CURRENT_USER\Software\Autodesk\DWG TrueView in the registry. Export it to a reg file and install that prepared profile for the end user. This includes any custom files like ctb, pc3, fonts etc.
You can also make sure that this happens if another user logs in on that PC. Otherwise that user will have the default profile.

Previous post on the release of DWG TrueView.

>>>Update

If the settings in Options should be distributed it should be taken in consideration that some paths are saved pointing to user locations like C:\Documents and Settings\jimmy.bergmark\Application Data. Therefore you have to just take some of the settings. (Update. See the usage of environment variables in the end of the post)

Below &lt;&lt;Unnamed Profile&gt;&gt; there can be several paths that have to be handled. I recommend that these are removed from the reg file or that you just keep those that you actually need to change. E.g.:

[HKEY_CURRENT_USER\Software\Autodesk\DWG TrueView\R2\DWGV-4001:409\Profiles\&lt;&lt;Unnamed Profile&gt;&gt;\General]
"PrinterConfigDir"="C:\\PHEM\\Autodesk\\AutoCAD\\16.2\\plotters"
"PrinterDescDir"="C:\\PHEM\\Autodesk\\AutoCAD\\16.2\\plotters\\PMP Files"
"PrinterStyleSheetDir"="C:\\PHEM\\Autodesk\\AutoCAD\\16.2\\Plot Styles"

For adding support paths I instead recommend that you copy what you need to the following paths. Typically you might want to add fonts, shapes, linetype files and so on.

C:\Program Files\Autodesk\DWG TrueView\Support
C:\Program Files\Autodesk\DWG TrueView\Fonts

>>>Update 2005-11-03 based on the comments of R.K. McSwain.

At his blog post he shows the usage of windows environment variables for the support file search path.
%ALLUSERSPROFILE% returns the location of the All Users Profile.
%APPDATA% returns the location where applications store data by default.
%PROGRAMFILES% returns a path like "C:\Program Files".

There is also another way to run the installation and to get all supporting installations installed if needed using setup.exe and run it in a silent mode. Change the setup.ini file and the following rows (changed text is bold):
SETUP_STARTUP_MESSAGE=NO
INSTALL_CMD_ARGS=/qb! /L*v %temp%\DWGVInstall.log INSTALLDIR="C:\Program Files\Autodesk\DWG TrueView" ACAD_SILENT_LICENSE=YES

>>>Update 2005-11-03 Added the arguments INSTALLDIR and ACAD_SILENT_LICENSE