Blog of the Bao-‘dad’ Tree

Reaching out   –   Giving back   –   Looking inward   –   Paying forward 

Office VBA: Installing Self-signed Digital Certificates

First you need to create a self-signed digital certificate by going to Start > Programs > Microsoft Office > Microsoft Office Tools > Digital Certificate For VBA Projects (this is actually a shortcut to %PROGRAMFILES%\Microsoft Office\OFFICE11\SELFCERT.EXE).

Next, you need to sign your VBA code project in the VBA IDE by going to the Tools menu > Digital Signature... and pressing "Choose" to choose the certificate you created above.

So far, this is relatively straightforward.  The problems come when you're trying to re-install certificates after an OS re-install.  Or trying to install certificates on someone else's machine.  Here are some clues I've found:

1. The actual certificate files are stored in %APPDATA%\Microsoft\SystemCertificates\My\

2. There's a snap-in called Certmgr.msc which helps you manage certificates.  You want to drag your self-signed certificate into the Trust Root Certification Authorities > Certificates folder.

3. When you open a MS Office file that has signed code in it, you want to try to "View Certificate" and "Install Certificate" if you can.  Or "Always Trust Macros From This Publisher".  Here is a good link on some resources to help you.

I'll continue to be on the lookout for more information about backing up and restoring certificates before and after a machine reinstall.

Comments [0]

Outlook Contact List Problems When Moving To Another Machine

This is probably not of interest to any of you.  I'm just posting it here because it's a problem I frequently face at work and I want to remember where the link is to solve it.  Here it is.

Basically, when I reformat a computer or move one of my users to a new computer, I migrate their Outlook .pst file that contains all their mail and contacts.  However, unless I follow the steps in this link, they cannot add addresses to emails from their Outlook contacts.

Comments [1]

Windows Command-line Tool: SubInACL

One of Windows' strengths in the ability to apply very granular, detailed permissions to your file system and shares.  However, this makes for some fairly complex permissions settings.  One of Windows' weaknesses is its command line (which had been more than remedied with PowerShell, I think).  But I found a tool today that enables me to take ownership of files and folders from the command prompt.  It's called SubInACL.  It looks like the ultimate Windows command-line ACL tool.  (CACLS.exe is just a joke.  It can only do the simplest of things.  And the /T option doesn't descend down more than one directory deep.)

Here's the command I used to take ownership of everything in the current directory:
subinacl /file * /setowner=me

Comments [0]

Meet Our Newest Addition, "Nibbles"

Almost four years ago for my birthday, my family got me a betta fish I named "Herman Schnauzer."  He was a good fish, but this last week he took his last breath, and went to the happy swimming pool in the sky.  He almost made it four years with us.

This week at work, I've caught two mice!  One with the amazing, humane, "Mice Cube," which I highly recommend.  No one I've ever talked to has ever failed to make a catch with this trap.  This was my second with one.  But yesterday, we found the little toddler mouse whose mother we did away with the day before.  We found him wandering around under the desks in the daytime, the poor little guy.  I put a Cheeto out on the floor and he came out and grabbed it and ran back under the desk.  So I named him "Cheeto."  He came right out in to the open again, apparently not that afraid of all of us in the office who were watching, and I caught him with a cardboard box.  He was such a tiny, adorable, little mouse, I brought him home and was going to keep him; but the internet convinced me that it's not exactly safe to take a wild or house mouse as a pet.

So today I stopped by the pet store.  We still had Cheeto in his box, and I was thinking I would buy him a friend, and they had these cute little dwarf hamsters at the pet store.  So I bought one and brought it home.  The dwarf hamster is small but still over twice as large as Cheeto.  I ended up setting Cheeto free in our backyard.  And the hamster we named "Nibbles."  The pet store people agreed she is a girl.

This is her sleeping in the bottom tier of the Critter Universe Great Wall.  She can't jump at all, so she can't even make it up to the higher levels.  Cheeto would've done it no problem.

As I get older I think I'm realizing that I like animals, smaller ones generally, more than I realized.

Comments [2]

Strong Passwords and Online Safety

This article is a must-read for everyone who wants to work safely on the internet.

Personally, I use Keepass to keep all my passwords saved on my computer in an encrypted format.  And I use LastPass together with my browser to automatically fill in passwords on websites that I regularly surf to - however, I do not allow LastPass to save any passwords or login information for any of my financial sites.  I enter that using Keepass's autotype feature.

I know it's convenient to have your browser store "cookies" so that websites remember your information from visit to visit, but this is the setting I use in Firefox right now so that cookies are not saved after I close Firefox:

Comments [0]

Problems After Restoring a Cloned Hard Drive Partition

I've never had this problem before, but then today was the first time I had restored a disk partition image from another partition on the same disk.  I could not login (it was giving me an error about my paging file being absent or too small - which shouldn't matter because Windows can and should create a new one automatically).  I tried a lot of things, including running FIXBOOT and FIXMBR from the recovery console.  I also ran CHKDSK, which did fix a few important errors, but it wasn't until I followed these instructions down through step 6, then after hive is loaded, delete all entries in the HKLM\SYSTEM\MountedDevices registry key (except for default), then reboot.  Windows will rebuild the key automatically at next startup.  The rest of the steps aren't necessary.

In short,
1. CHKDISK
2. Boot to some kind of CD-ROM or USB based live OS that has a tool to edit the registry.  You can use Bart PE or Ultimate Boot CD.  I actually used the "Offline NT Password & Registry Editor" tool on the UBCD4WIN.
3. Load the %systemroot%\system32\config\SYSTEM registry hive and delete everything in the HKLM\SYSTEM\MountedDevices registry key
4. Reboot

Additionally, sometimes I have also had to edit the registry key for Windows' userinit.exe settings in order for my log in to work. These instructions are helpful.  In a nutshell, edit HKLM\Software\Microsoft\Windows NT\Current Version\Winlogon\Userinit so that it is just "userinit.exe" instead of "C:\WINNT\system32\userinit.exe" (without the quotes in both cases).  (I think even changing it to just "userinit" will work too.)

Comments [0]

Mount USB Drive in System Rescue CD

From the forum: 
You can run "fsarchiver probe simple" from sysresccd-1.1.7 to identify all the filesystems
 
Once you know the device, (probably /dev/sdb or something like that) just
 
mkdir /mnt/usb
then
mount /dev/sdb (or whatever) /mnt/usb 

Comments [0]

The Book of Mormon

I love the Bible.  It is the word of God.  I am also thankful for the Book of Mormon.  It is also the word of God.  How much poorer I would be without passages such as these:
   I will go and do the things which the Lord hath commanded, for I know that the Lord giveth no commandments unto the children of men, save he shall prepare a way for them that they may accomplish the thing which he commandeth them (1 Nephi 3:7).
   Adam fell that men might be; and men are, that they might have joy (2 Nephi 2:25).
   For we labor diligently to write, to persuade our children, and also our brethren, to believe in Christ, and to be reconciled to God; for we know that it is by grace that we are saved, after all we can do (2 Nephi 25:23).
   Wherefore, ye must press forward with a steadfastness in Christ, having a perfect brightness of hope, and a love of God and of all men. Wherefore, if ye shall press forward, feasting upon the word of Christ, and endure to the end, behold, thus saith the Father: Ye shall have eternal life (2 Nephi 31:20).
   For the natural man is an enemy to God, and has been from the fall of Adam, and will be, forever and ever, unless he yields to the enticings of the Holy Spirit, and putteth off the natural man and becometh a saint through the atonement of Christ the Lord, and becometh as a child, submissive, meek, humble, patient, full of love, willing to submit to all things which the Lord seeth fit to inflict upon him, even as a child doth submit to his father (Mosiah 3:19).
   For how knoweth a man the master whom he has not served, and who is a stranger unto him, and is far from the thoughts and intents of his heart? (Mosiah 5:13)
   And behold, he shall be born of Mary, at Jerusalem which is the land of our forefathers, she being a virgin, a precious and chosen vessel, who shall be overshadowed and conceive by the power of the Holy Ghost, and bring forth a son, yea, even the Son of God.
   And he shall go forth, suffering pains and afflictions and temptations of every kind; and this that the word might be fulfilled which saith he will take upon him the pains and the sicknesses of his people.
   And he will take upon him death, that he may loose the bands of death which bind his people; and he will take upon him their infirmities, that his bowels may be filled with mercy, according to the flesh, that he may know according to the flesh how to succor his people according to their infirmities (Alma 7:10-12).
    Yea, and cry unto God for all thy support; yea, let all thy doings be unto the Lord, and whithersoever thou goest let it be in the Lord; yea, let all thy thoughts be directed unto the Lord; yea, let the affections of thy heart be placed upon the Lord forever.
   Counsel with the Lord in all thy doings, and he will direct thee for good; yea, when thou liest down at night lie down unto the Lord, that he may watch over you in your sleep; and when thou risest in the morning let thy heart be full of thanks unto God; and if ye do these things, ye shall be lifted up at the last day (Alma 37:36-37).
   And now, my sons, remember, remember that it is upon the rock of our Redeemer, who is Christ, the Son of God, that ye must build your foundation; that when the devil shall send forth his mighty winds, yea, his shafts in the whirlwind, yea, when all his hail and his mighty storm shall beat upon you, it shall have no power over you to drag you down to the gulf of misery and endless wo, because of the rock upon which ye are built, which is a sure foundation, a foundation whereon if men build they cannot fall (Helaman 5:12).
   And if men come unto me I will show unto them their weakness. I give unto men weakness that they may be humble; and my grace is sufficient for all men that humble themselves before me; for if they humble themselves before me, and have faith in me, then will I make weak things become strong unto them (Ether 12:27).
    Behold, I would exhort you that when ye shall read these things, if it be wisdom in God that ye should read them, that ye would remember how merciful the Lord hath been unto the children of men, from the creation of Adam even down until the time that ye shall receive these things, and ponder it in your hearts.
   And when ye shall receive these things, I would exhort you that ye would ask God, the Eternal Father, in the name of Christ, if these things are not true; and if ye shall ask with a sincere heart, with real intent, having faith in Christ, he will manifest the truth of it unto you, by the power of the Holy Ghost.
   And by the power of the Holy Ghost ye may know the truth of all things (Moroni 10:3-5).

Comments [1]

psexec Computer Trick

From my computer, I can open a cmd console screen with a message on it on another computer using psexec.  Here's how:
  1. I need to already have administrative privileges on the target computer.
  2. psexec needs to be installed on my computer.
  3. I create a batch file that looks like this: 
    @echo OFF
    echo Tell me if you got this.
    echo.
    pause
    del %0
    (The last line is the batch file "self-destruct" command.)
  4. I open a command window, and type  psexec \\targetcomputernameorIP -i -c "C:\path\to\file.bat"
The -i switch runs the process interactively with the logged on user.  The -c switch copies the file to that computer before running it.

Comments [0]

Step-through VBscript Debugging

First of all, let me say at the outset that if there is any way at all you can use Windows Powershell instead of VBscript, do it.  Powershell is the future of Windows scripting.

But we all have to go back and fix things from the past sometimes, and when we do it's nice to have some tools.

One of the great tools I use is Notepad++, a free and highly configurable text editor for Windows.

You can configure Notepad++ to open up a debugging program to step through the file you've currently got open.  First you have to edit your %APPDATA%\Notepad++\shortcuts.xml file.  In the <UserDefinedCommands> element, add this line:

<Command name="Debug VBscript" Ctrl="no" Alt="no" Shift="no" Key="0">wscript.exe //D //X &quot;$(FULL_CURRENT_PATH)&quot;</Command>

This will add a command to the Notepad++ "Run" menu, that will execute the currently saved version of your open file with wscript.exe, with the //D switch to tell it to debug if it encounters any errors, and the //X switch to immeditely throw an error at the beginning of execution.

Next, what debugger should you use?  Often you can get Microsoft Script Debugger to come up, but if it all possible, see if you can use Microsoft Script Editor.  Microsoft Script Editor comes with Microsoft Office; I can find mine in %PROGRAMFILES%\Microsoft Office\OFFICE11.  It's called MSE7.EXE.

It took a little doing to figure out how to get it to come up as a debugger.  I think this registry edit should do the trick.  Create a .reg file with these contents and merge it with your registry [Disclaimer: DO ONLY AT YOUR OWN RISK!  Making a mistake modifying the registry can crash your computer]:

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Machine Debug Manager\JITDebugging\Engines\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2}]
@="Script Only"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Machine Debug Manager\JITDebugging\Engines\{F200A7E7-DEA5-11D0-B854-00A0244A1DE2}\{000C1227-0000-0000-C000-000000000046}]
@=""
"Remote"=dword:00000001

For more help check here:
http://support.microsoft.com/kb/308364

Comments [2]