Thursday, December 31, 2015

Generating OPC Automation IDL, TLB and header files from OPCDAAuto.dll

OPC Automation IDL, TLB and header files are not easy to find. You can obtain this files from OPC Foundation if you are a member or maybe from OPC application vendor.

The IDL file can be reverse engineered using OLE-Com Object Viewer. Once the IDL is generated TLB and other files can be generated from it as well. Below is a general direction how to do this.

Steps to reverse generate IDL, TLB and header files for OPCDAAuto.dll:

  1. Download Windows 7 SDK. I am using GRMSDKX_EN_DVD.iso as the OS is Windows 7 64-bit.
  2. Install the SDK.
  3. Open CMD Shell (Start | All Programs | Microsoft Windows SDK v7.0 | CMD Shell)
  4. Change directory to bin folder.
  5. Run oleview.exe, this will open a 32-bit version of the application. Note that this is important as the OPCDAAuto.dll I have is 32-bit as well.
  6. Navigate to Type Libraries | OPC Automation 2.0 (Ver 1.0)
  7. Double click to view Type Library definition.
  8. Do File | Save As... to D:\OPCDaAuto\OPCDaAuto.IDL.
  9. Go back to the cmd.exe as per step 3. Change directory to D:\OPCDaAuto.
  10. Fix OPCDaAuto.IDL
    1. Compile the IDL file, like, midl /win32 OPCDaAuto.IDL /header OPCDaAuto.h 
    2. This will fail about OPCGroups type specification.
    3. Fix this by moving OPCGroups definition in line 188-195 to line 104, this is above OPC Server Object. Save the file, this will change the numbering.
    4. Compile again as per sub-step 1 above.
    5. This will fail again about single type specification. Change single to float for the lines as per the output of the compilation.
    6. Compile again. This time it will complain about OPCGroup type specification.
    7. Fix this by moving OPCGroup around line 255-262 to around line 196. This above definition of Collection of OPC Group Objects.
    8. Compile again. This will fail again for another single data type. Convert it to float in 2 more places. Line location should be indicated in the compilation output.
    9. Compile again. This time it should be successful.
Note that I haven't used the corresponding TLB and header files, yet. I am hoping it will work.

Saturday, December 12, 2015

Check Windows input message queue idle in Python

Code below shows how to check for message queue input idle. Note that WaitForInputIdle waits only once per process on any thread. So if one of the thread returns idle then it will return right away. 

Tested on:
Windows 10 TH2 (build 1511)
Python 3.5.1 64-bit

Also need to install pywin32, like:
c:\> pip install pypiwin32
This should be run on elevated prompt.

Saturday, December 05, 2015

How to resolve external hosts when using pfSense as firewall/router

pfSense 2.2.5 does not automatically resolve external hosts (but not hosts from the internet) using DNS servers provided by DHCP from the WAN interface. To force it resolve, do:

Navigate via Web UI:

  • Services | DNS Resolver
  • Scroll down to Domain Overrides
  • Add entry
    • Domain: [a domain suffix, e.g.,]
    • IP address: [DNS server IP]

What are the side effects without the above changes?

  • pfSense clients not able to access internet, especially when internet is controlled via a proxy.
  • Windows clients unable to access Windows share even using FQDN

Windows 10 Mail app "Something went wrong We're sorry, but we weren't able to do that."

Upgraded from Windows 8 to Windows 10, Mail app stopped working with the following message

Something went wrong
We're sorry, but we weren't able to do that.
Error code: 0x8007000d.

Workaround is to re-install the app, see to remove it. Once removed you can go to Windows Store to install Mail again.

How to remove Windows 10 Mail and Calendar app

c:\> Get-AppxPackage | Where-Object {$_.Name -like "*microsoft.windowscommunications*"} | Remove-AppxPackage

Note that you have to run PowerShell in elevated mode.

Friday, November 27, 2015

How to get Windows 10 version number

Method 1: Using GUI, type the following from the command prompt or Run dialog
c:\> winver
Method 2: Using systeminfo, from the command prompt do:
c:\> systeminfo | findstr /C:"OS Version:"
Method 3: wmic, from the command prompt do:
c:\> wmic os get version

Windows 10 Enterprise Threshold 2 build 1511 screenshots

Monday, November 23, 2015

Windows 2016 Technical Preview 4 screenshots

Windows 2016 Technical Preview screenshots below.

Note: Need flash plugin for it to work.

Wednesday, September 16, 2015

Start a remote process using wmic

c:\>wmic /node:REMOTENODE process call create "notepad"

Monday, September 14, 2015

Uploading custom project homepage to Srouceforge

It took me a while to find the latest instructions on how to upload my own webpage for my project in Sourcefoge. I have shamelessly copied the instructions below for posterity.

For managing Project Web space

Project web Hostname:
Path: htdocs/
Username: Combine your Username with your project UNIX name using a comma ( "," ) See Example
Password: Your Password
An example session might look like the following for Username "jsmith" uploading a file for his project with a UNIX name of "fooproject":
[jsmith@linux ~]$ sftp jsmith,
Connecting to
The authenticity of host ' (' can't be established.
RSA key fingerprint is 68:b3:26:02:a0:07:e4:78:d4:ec:7f:2f:6a:4d:32:c5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
jsmith,'s password:
sftp> cd htdocs
sftp> put index.html
Uploading index.html to /home/groups/f/fo/fooproject/htdocs/index.html
index.html                                                                                       100%  241     0.2KB/s   00:01
sftp> exit


Sunday, September 13, 2015

How to shutdown android-x86 pC

Press Alt+F1, then type:

#: reboot -p


Saturday, September 12, 2015

Saturday, August 08, 2015

The panel encountered a problem while loading "TrashAppletFactory::TrashApplet"

Installed Ubuntu 15.04 CLI (network install), then installed Ubuntu MATE minimal installation. The issue is that every time I login I run into an application crashing.

The panel encountered a problem while loading "TrashAppletFactory::TrashApplet"

 I am guessing that this is for the Trash Can on the desktop, clicking on Delete will prevent this error message from showing up again next time. Of course you will not have the Trash on the desktop.


Monday, August 03, 2015

Windows 10 goes blank screen on VirtualBox after several minutes of inactivity

Might be related to Power Options. Running some experiments now.

Experiment #1:
Power Options | Hard disk | Turn off hard disk after | Plugged in = Never

Windows 10 E LTSB does not have Microsoft Edge

Yes, Windows 10 Enterprise Long Term Servicing Branch (LTSB) does not have Microsoft Edge. :(.

Sunday, August 02, 2015

Windows 10 OneNote Sorry something went wrong

Created Windows 10 Enterprise VM using a local account then associated with Live ID/Microsoft Account, then dis-associated again as I was using the wrong ID. Re-associated with another account, it seems to work but OneNote is having problem. Error shows like:

Sorry, something went wrong.
We are unable to sign you in. Please try again later.

Re-tried and re-tried nothing works. The workaround is to uninstall and then reinstall OneNote. Unfortunately, OneNote is one of the built in applications and cannot be removed using Apps & Features in SYSTEM settings. To uninstall, drop to PowerShell with elevated/administrative privileges and run the following:

PS C:\> Get-AppxPackage ** | Remove-AppxPackage

Once removed, open Store (Windows Store application) then install OneNote. Launching OneNote should now ask for new credentials. Have fun!


Saturday, August 01, 2015

PowerShell Quick Tips: Rename a computer

Rename local computer to W8M1 and restart
PS D:\> Rename-Computer -NewName W8M1 -Restart
The above command works with Powershell 3.0. For Powershell 2.0, below can be used on an elevated privileges.
PS D:\> $computer = Get-WmiObject Win32_ComputerSystem -ComputerName <old_name>
PS D:\> $computer.Rename("<new_name>")
PS D:\> $os = Get-WmiObject Win32_OperatingSystem
PS D:\> $os.psbase.Scope.Options.EnablePrivileges = $true
PS D:\> $os.Reboot()

Using WMIC to rename a computer
D:\> WMIC ComputerSystem where Name="%computername%" call Rename Name=NewName


Wednesday, June 03, 2015

Windows 10 E B 10074 text corruption in File Explorer

Just installed Windows 10 Enterprise build 10074. First impression? Feels slower than build 10041. Also noticed that File Explorer shows corrupted string in Quick Access folder.

[6/3/2015] Same issue is observed on Windows Server Technical Preview 2 (Windows 2016).

Tuesday, June 02, 2015

File Explorer crashed on exit when shutting down Windows Server Technical Preview 2

File Explorer crashed on exit when shutting down Windows Server Technical Preview 2 (Windows 2016).

Note this I cannot reproduce this one.

Project Spartan (Edge) does not open on the default Administrator account on Windows 2016

Looks like Microsoft is now getting really serious with security. Their newest browser, code named "Project Spartan" or Edge, does not run if the user is the default administrator account on Windows 2016 (Windows Server Technical Preview 2).

How to install GUI on Windows Server (2016) Technical Preview 2

Windows Server Technical Preview 2 (Windows Server 2016?) does not have the option to install the full GUI.
Figure 1.
 It does have the option to install minimum shell (MinShell). This will provide access to Server Manager and the cmd.exe as shown below.
Figure 2.
The GUI can be installed, that I know of, either using Server Manager or PowerShell.

To install using Server Manager, do Manage | Add Roles and Features. Hit on Next button using the default selection until you reach Features dialog. Under the feature User Interface and Infrastructure, select Server Graphical Shell.
Figure 3. Feature dialog
Progress the dialog/wizard window until completion.

Power users can also install the GUI using PowerShell, like:

PS C:\>Install-WindowsFeature Server-Gui-Shell -Restart


Windows mounted volume does not work on Virtualbox vboxsf

I have Windows 8.1 with VirtualBox 4.3.28 installed. On VM running Ubuntu 15.04, tried to mount Windows using VirtualBox Shared Folder using vboxsf. The issue is that this mounted volume in Linux does not know how to handle mounted Windows volume.

Wednesday, May 06, 2015

pip fails to run on Windows 10 E build 10074

Installed Windows 10 E 64-bit build 10074, followed by Python 2.7.9 32-bit. Running pip fails the with message

Fatal error in launcher: Job information querying failed
Issue is open in Github, see below

This issue is also reported in, see

C:\>python -m pip install comtypes

Saturday, April 25, 2015

Updating Eclipse Kepler shows 'Backup of file eclipse.exe failed'

Tried to update Eclipse Kepler but failed with message below.
An error occurred while uninstalling
session context was:(profile=epp.package.testing, phase=org.eclipse.equinox.internal.p2.engine.phases.Uninstall, operand=[R]org.eclipse.rcp.configuration_root.win32.win32.x86 1.0.0.v20130521-1847 --> null, action=org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CleanupzipAction).
Backup of file D:\eclipse\eclipse.exe failed.
Can not remove : D:\eclipse\eclipse.exe
The workaround?

  1. Rename existing eclipse.exe to say eclipse1.exe
  2. Run eclipse1.exe
  3. Do Eclipse update 

Change Tfs scrum working days

By default Tfs scrum template sets Monday to Friday as working days, and Saturday/Sunday as excluded. To change the days or include Saturday/Sunday for the work, do:

  1. Click on the "Administer Account", this is the gear icon.
  2. Navigate to Control Panel > [CollectionName] > [Project] > [Project] Team.
  3. Click on Settings, then change as appropriate.

Tested on Tfs 2013/Visual Studio online (as of 04/25/2015)

Fix corrupted console font on Ubuntu 15.04

My tasksel looks like below.

To fix this do:

$: sudo dpkg-reconfigure console-setup

Then select:
  •  UTF-8
  • Guess optimal character set
  • Terminus
  • 8x16
Select different font type as appropriate.

tty;console;command line;cli install


Sunday, April 05, 2015

Get domain controller from NetBios name using Python

     myad is the NetBios name of the domain.

Note: Using ActiveState Python 2.7.x.

Get domain controllers from the command line using nltest

c:\> nltest /dclist:myad.test.local
This will return list of domain controllers for myad.test.local domain.

Get PDC domain controller name using nltest

c:\> nltest /dcname:myad
Note using myad(NetBios) instead of FQDN.

Get domain roles from the command line

c:\> netdom query /domain:myad.test.local fsmo

This can be used to get the PDC (Primary Domain Controller) emulator on AD environments.