Friday, December 02, 2011

Useful Sysinternals Utilities

As a software engineer (not system administrator), I found the following tools from Sysinternal to be useful.
  • Autoruns: mainly used to turn off unnecessary executables during boot and login to speed up system boot performance
  • Portmon: used to monitor serial port traffic (similar to wireshark for network traffic)
  • Process Explorer: used mainly to find file locks, so that I know which process to kill to be able to free up the lock.
  • Process Monitor
  • PsExec: remote execute console application. Examples:
  • psexec \\vm-001 ipconfig /all
  • psexec \\vm-001 cmd
  • This command copies the program test.exe to the remote system and executes it interactively: psexec \\vm-001 -c test.exe
  • PsKill: kill local or remote processes. Mainly used in server software for house keeping (for example: kill stuck Office Automation process)
  • PsService
  • ZoomIt: usefuly for presentation. Zoom in screen, draw lines on the screen.

Friday, October 28, 2011

Disable Touchpad on Dell Laptop

Problem
Ever frustrated with Touchpad being overly sensitive?

I frequently got random mouse movements and clicks while using Laptop's keyboard. They are caused by the Touchpad being overly sensitive. It is especially a problem when I am using remote desktop working on another computer. I guess the Touchpad sensitivity settings does not work on remote desktop client?

And this is a major frustration, because when I finish typing a line of code, they frequently show up on the wrong line, and did not show up anywhere at all, because the random mouse clicks has took their focus away.

Research
Today, finally it struck me that I should disable this thing. And turns out the latest DELL tool has some nice options available. For one thing, I can permanently enable/disable "Pointing Stick", "Pointing Stick Buttons", "Touchpad", and "Touchpad Buttons". But, there is also a very nice feature called: "Disable Touchpad/Point Stick when external USB mouse is present". This is really a very user friendly feature that I never thought of searching for before.

Conclusion
I put a check next to the option:  "Disable Touchpad/Point Stick when external USB mouse is present", and got a wireless mouse. Problem solved. Happily typing code again.

Monday, October 10, 2011

Portable Mouse with a Hook or Loop

Goal: to allow portable mouse to be even more portable

Going to meeting with a laptop, a pen and notebook (made with paper) and a mouse can be a handful (not to mention when you have a cup of coffee). What if we have a hook or ring on the mouse so that it can dangle on a finger (or belt?).
 
Potential Solutions
- retractable ring
- foldable ring
- hook

Need to pay attention of location of ring or hook so that they don't interfere with normal mouse use.

Saturday, September 03, 2011

Adobe Flash Builder 4 and Coldfusion Builder crash during startup

Symptom: all of sudden, my Flash Builder 4 and Coldfusion Builder can not be started. They will crash during start. They are running on Eclipse 3.4.2, and 3.5.2 respectively.

Diagnostic: Coldfusion builder simply show me an error dialog without any useful information. It just generically states something like: Visual C++ request application to exit in abnormal way.
Of course, I tried to reset Eclipse and clear it's workspace to no avail.
However, luckily, Flash Builder 4 throws an exception. And I got a chance to start Visual Studio 2010 debugger session on it. Once in Visual Studio debugger, I saw exception type "bad_day_of_month" from boost library. Then I turn to "Stack Trace" tab, and saw callstack: Kernel32->atmlib.dll->UpdateNotifications.dll. A little Google on this end turned up a thread talking about similar problem from other Adobe users. So, I read the thread, it starts to mention how the "UpdateNotification" library will look at Windows Scheduled Tasks for Adobe updater. Then it occurs to me what might be, and later proven to actually be the root cause.

Cause: A few days earlier, in an effort to speed up my computer, I ran "AutoRuns" utility from "System Internals", and disabled a bunch of "Scheduled Tasks". Among them was a task named "AdobeAAMUpdater-1.0......".

Fix: using "AutoRuns" utilities, I turned the "AdobeAAMUpdater-1.0....." scheduled task back on. Then Flash Builder 4 and Coldfusion Builder are all back to normal.

Monday, August 08, 2011

SQL Maintenance Plan Failed

Environment: SQL 2005
Symptom: Scheduled SQL maintenance plan to do partial backup failed. Got two message logged in SQL Server log:
Error: 3041, Severity: 16, State: 1
BACKUP failed to complete the command BACKUP DATABASE master WITH DIFFERENTIAL. Check the backup application log for detailed messages.
Cause: Master database does not support partial backup. So, if the task is for "Differential" backup, "master" database should not be included.
Solution: Open the plan details, in the "Database(s)" section make sure database that needs to be backup are explicitly selected, instead of having "All databases" checked.


Monday, August 01, 2011

Coldfusion Webservice Input Name Changed to in0

Symptom: Coldfusion webservices sometimes complain about input parameter "In0"

Environment: Coldfusion 9 on Windows

Solution: Login to Coldfuion 9 Administrator portal, Go to Server Settings > Caching, click on "Clear Template Cache Now" and "Clear Component Cache Now". This seems to trigger to re-compile of webservices WSDL thus fixed the problem.


However:
  1. I don't know what is the root cause of this problem. Google turn-up some similar complains, but could not find any official answers on this
  2. The solution which required human interaction does not help in production environment
  3. The solution does not solve the problem permanently, sooner or later I'll hit the same error, and has to go back to the server and clear cache again

Wednesday, May 11, 2011

CFQUERYPARAM: LIST and SEPARATOR attributes

Adobe online document only listed these two attributes without much explanation. I found the following link with very thorough explanation of the effects and usage of these two attributes:
http://www.pukkared.com/2011/01/using-cfqueryparam-list-attribute-when-using-in-operator/

Tuesday, May 03, 2011

NUnit Integration With Visual Studio 2010

I just discovered the perfect tool for NUnit integration: Visual Nunit 2010

Here are the pros:
  • Open source, Apache License
  • GUI: I personally like it better than the official Nunit GUI
  • Visual Studio Integration: of course, this is the #1 reason I try it out, and I'm completely satisfied
  • Load config file without problem (Nunit project does not load config files correctly)
  • Debug: attach to Nunit or Nunit-agent is no longer needed, simply set breakpoints and click the red  arrow to start debug session
  • Easy drilldown of test cases
  • One click to execute any individual test cases
Cons? None so far.

Thursday, April 21, 2011

Server Side Office Automation using ColdFusion

Tips after fighting to get robust Office Automation using ColdFusion 9.


Definitions
COM: Microsoft Component Object Model.
Automation: the process of launching another application and controlling it programmatically through a public interface.

Environment
ColdFusion 9
Office 2007 SP2

Tips
  • Pay attention to Office version (down to minor rev numbers), I encountered several major differences  between Office 2007, and Office 2007 SP2 (no to mention the differences between 2003 and 2007)
  • Server setup
    • CF service account must be interactive
    • Office installation need to select option to install all features locally
    • After Office installation, need to login as service account, and start Office applications and click through license agreement, registration, ...
  • Open Office applications with Visible=false may have negative impact on it's behavior (At least for Powerpoint, I found some layout options are not functioning correctly if application is started in invisible mode. Specifically, I was trying to set text box property: "Shrink text on overflow", by setting AutoSize=2 (msoAutoSizeTextToFitShape), it won't work unless Powerpoint application is created in visible mode.)
  • Before even start ColdFusion code, I usually test my script using VBS, then translate to CFScript, however, CFScript have some minor difference from VBS:
    • VBScript can use array notation or foreach on some collections, but CFScript  usually has to access the 'items' accessor
    • Explicit type conversion may be necessary in some COM function calls, use "JavaCast". In my case, I got this error message:
An exception occurred when executing a COM method. 
The cause of this exception was that: AutomationException: 0x80048240 - Item 1 not found in the Designs collection. in 'Microsoft Office PowerPoint 2007'. 
Code causing the problem: objPresentation.Designs.Item(1)
Reason: ColdFusion is not type safe. COM definition for this input parameter is variant type. Seems like ColdFusion trying to send it over in string format "1" instead of numeric value 1.
Solution: objPresentation.Designs.Item(JavaCast("int", 1))
    • VBScript can use enumerates just by name, CF does not have that luxury, you have to find out the numeric values for each of the enumerations, please see my other post for list of some numeric values: Some Enum Values for Office COM Object.
  • To find out numeric values, I used Visual Studio to add reference to Office library, then I can easily navigate or search for enums
  • One way to implementation robust automation:
    • Main CFC
      • Create a worker thread to do automation task
      • Wait for the thread with timeout
      • After wait is finished, if it's timeout, will kill automation application, kill thread, and cleanup, else we have successfully done!
    • Automation thread
      • Global lock on Office Application name (avoid concurrency issue)
      • Create automation object
      • <<do you thing>>
      • quit automation object
      • ReleaseCOMObject
      • cleanup
  • To cleanup, I use "pskill" to kill office processes, so that a single failed call won't block all future automation attempts
  • Code segment to create automation object

Server Side Office Automation Problems
  • Office applications are not designed for server environment
  • Concurrency (Office applications are non-reentrant, STA based automation, use global shared resources)
  • Scalability
  • Security
  • May lock up on launch or any point during execution if there are modal dialog popup (typically you will see license agreement, error messages, “install on first use”, … dialogs)
  • License considerations: each client must have licensed copies of Office
  • Officially discouraged by Microsoft
“Microsoft does not recommend or support server-side Automation of Office”
Alternatives
  • CFSpreadsheet
  • HTML/XML based format for word and excel
  • OOXML (Open XML file format)
  • Excel Services (Since Sharepoint Server 2007)
  • Word Automation Services (Since Sharepoint Server 2010)
  • Server libraries: Apach POI, Microsoft Open XML SDK
Reason to Stick with Automation Approach
  • After the above "Problems" section, the biggest incentives to use automation are
    • Need to invoke Excel macro or solution package on server side
    • You already have some fancy VBS code that can do what you wanted through Office automation

References

Adobe. 2011. ColdFusion Developer’s Guide. Last Accessed April 19, 2011. http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_4_CF_DevGuide_1.html
Forta, Ben and et al. 2005. Advanced Macromedia ColdFusion MX 7 Application Development, Chapter 26 Extending ColdFusion with COM. Macromedia Press. http://www.forta.com/books/0321292693/0321292693_chapter26.pdf
Microsoft. 2011. KB 257757: Considerations for server-side Automation of Office. Last Accessed April 19, 2011. http://support.microsoft.com/kb/257757

Friday, March 25, 2011

Some Enum Values for Office COM Object

Actual integer values for several Office 2007 (12.0) COM Enums

Microsoft Office Core


MsoAutoSize

msoAutoSizeMixed-2
msoAutoSizeNone0
msoAutoSizeShapeToFitText1
msoAutoSizeTextToFitShape2

Word


WdSaveFormat

wdFormatDocument970
wdFormatDocument0
wdFormatTemplate971
wdFormatTemplate1
wdFormatText2
wdFormatTextLineBreaks3
wdFormatDOSText4
wdFormatDOSTextLineBreaks5
wdFormatRTF6
wdFormatUnicodeText7
wdFormatEncodedText7
wdFormatHTML8
wdFormatWebArchive9
wdFormatFilteredHTML10
wdFormatXML11
wdFormatXMLDocument12
wdFormatXMLDocumentMacroEnabled13
wdFormatXMLTemplate14
wdFormatXMLTemplateMacroEnabled15
wdFormatDocumentDefault16
wdFormatPDF17
wdFormatXPS18
wdFormatFlatXML19
wdFormatFlatXMLMacroEnabled20
wdFormatFlatXMLTemplate21
wdFormatFlatXMLTemplateMacroEnabled22
wdFormatOpenDocumentText23

WdExportFormat

wdExportFormatPDF17
wdExportFormatXPS18

WdAlertLevel

wdAlertsMessageBox-2
wdAlertsAll-1
wdAlertsNone0


PowerPoint


PpSaveAsFileType

ppSaveAsPresentation1
ppSaveAsPowerPoint72
ppSaveAsPowerPoint43
ppSaveAsPowerPoint34
ppSaveAsTemplate5
ppSaveAsRTF6
ppSaveAsShow7
ppSaveAsAddIn8
ppSaveAsPowerPoint4FarEast10
ppSaveAsDefault11
ppSaveAsHTML12
ppSaveAsHTMLv313
ppSaveAsHTMLDual14
ppSaveAsMetaFile15
ppSaveAsGIF16
ppSaveAsJPG17
ppSaveAsPNG18
ppSaveAsBMP19
ppSaveAsWebArchive20
ppSaveAsTIF21
ppSaveAsPresForReview22
ppSaveAsEMF23
ppSaveAsOpenXMLPresentation24
ppSaveAsOpenXMLPresentationMacroEnabled25
ppSaveAsOpenXMLTemplate26
ppSaveAsOpenXMLTemplateMacroEnabled27
ppSaveAsOpenXMLShow28
ppSaveAsOpenXMLShowMacroEnabled29
ppSaveAsOpenXMLAddin30
ppSaveAsOpenXMLTheme31
ppSaveAsPDF32
ppSaveAsXPS33
ppSaveAsXMLPresentation34
ppSaveAsOpenDocumentPresentation35
ppSaveAsExternalConverter36


PpAlertLevel
ppAlertsNone1
ppAlertsAll2


PpAutoSize
ppAutoSizeMixed-2
ppAutoSizeNone0
ppAutoSizeShapeToFitText1

PpSlideLayout
ppLayoutMixed-2
ppLayoutTitle1
ppLayoutText2
ppLayoutTwoColumnText3
ppLayoutTable4
ppLayoutTextAndChart5
ppLayoutChartAndText6
ppLayoutOrgchart7
ppLayoutChart8
ppLayoutTextAndClipart9
ppLayoutClipartAndText10
ppLayoutTitleOnly11
ppLayoutBlank12
ppLayoutTextAndObject13
ppLayoutObjectAndText14
ppLayoutLargeObject15
ppLayoutObject16
ppLayoutTextAndMediaClip17
ppLayoutMediaClipAndText18
ppLayoutObjectOverText19
ppLayoutTextOverObject20
ppLayoutTextAndTwoObjects21
ppLayoutTwoObjectsAndText22
ppLayoutTwoObjectsOverText23
ppLayoutFourObjects24
ppLayoutVerticalText25
ppLayoutClipArtAndVerticalText26
ppLayoutVerticalTitleAndText27
ppLayoutVerticalTitleAndTextOverChart28
ppLayoutTwoObjects29
ppLayoutObjectAndTwoObjects30
ppLayoutTwoObjectsAndObject31
ppLayoutCustom32
ppLayoutSectionHeader33
ppLayoutComparison34
ppLayoutContentWithCaption35
ppLayoutPictureWithCaption36

PpTextStyleType
ppDefaultStyle1
ppTitleStyle2
ppBodyStyle3