Category Archives: Utilities

Citrix Connection Error

3
Filed under Telecommuting, Troubleshooting, Utilities

I’m now in full rebuild mode after last weeks unfortunate RAID incident.


After installing Citrix Desktop and setting all my parms back up, I got


β€œThe desktop you are trying to open is currently available only to administrators. Contact your administrator to confirm that the correct settings are in place for your client connection.”


After some digging around, I came across this Citrix posting that was exactly the problem.


I had the Citrix Connection set to “Server”, it needs to be “Published Application”.


Too bad the error message itself didn’t actually mention that. But it’s hard to find too much fault in that.


 

PowerShell Curiosities

2
Filed under Software Architecture, Utilities

I’ve recently read several blogs about how great Windows PowerShell is, so I decided to check it out myself last night.

I didn’t get very far before I came across this on the download page:

“The .NET Framework 2.0 is required in order to install Windows PowerShell”

Ok, fair enough.

And then I proceeded to actually check out the download page, where they present no fewer than 20 different download options, including variants for “English” and “localized”, x86 and x64, plus Itanium.

First, I know from experience that it would be almost insane to suggest that small development shops try to maintain 20 different downloads of what is essentially the same product. MS can get away with this because they’ve got lots of money to throw at the problem, but is 20 different downloads of a command shell utility really justified? Ok, some of them are for some MultiLingual UI addon, so the total versions of the utility iself is fewer than that, but not by much.

The bigger issue I have here, though, is that I thought, and MS would surely have everyone believe, that the .NET runtime and the JIT compiler within should automatically be handling the differences between x86, x64 and Itanium. That’s the whole point of the JIT, right? The multilanguage versions? I can accept them, with reservations, but the different processor versions? I’m no expert on the PowerShell internals, but if it requires the .NET framework, that would seem to imply that it’s managed code, which would imply that the JIT should take care of the differences between platforms. And if it’s not managed code, why not? Is it that MS is saying that managed code is good enough for everyone else, but not good enough for them?

Reminds me of the discovery I made ages ago that Outlook communicates with Exchange via RPC, not via DCOM, even though DCOM was being pushed hard by Microsoft at the time. Another case of “good for you, not good enough for us”, perhaps?

Oh, and PowerShell looks like a very handy tool for Administrators. I’m sure I’ll find some uses for it eventually. But, get-childitems -path env: just to retrieve the current environment vars? There’s something to be said for mapping all sorts of various available info like that into a consistent interface, but my stack’s too deep as it is right now to pile this syntax on top just yet.

Automatic Process Priority Optimization

1
Filed under Utilities

I’ve been experimenting a lot lately with Apophysis for fractal generation, and one thing that bugs me is that when actually running a render, the program still runs at normal priority. Which means that even on a very fast dual core Core2 processor, my system just drags.

It’s easy enough to remedy; just use taskman to set the Apophysis Process to below normal priority. The render still runs full speed if you aren’t doing anything else on the machine, but it takes a backseat to anything else going on.

I’ve used this trick before for many purposes (Terragen, anyone!), and even used it within a Service process I wrote once. The service was fully multithreaded, and each thread adjusted it’s priority based on what it was doing.

Well, the frustration got a little much last night so I started looking for something that would automatically recognize processes as they come online and adjust their priority based on predefined settings.

Look no further, Process Priority Optimizerto the rescue. It’s a small utility that runs in the tray (what doesn’t anymore πŸ˜‰ ). You can set the preferred priority if a process, save, and then, if that process loads up again, it’s priority is automatically adjusted.

UPDATE:

Even better, Ralf pointed me to a program called ProcessTamer. It looks even better than Process Priority Optimizer, because it will automatically adjust the priority of processes that are running hot, no preconfiguration necessary. The latest version also supports specific configurations for particular applications, which is what the Optimizer will do While.

I’m all for apps that handle things transparently (unless, of course, I want to configure it, I’m fickle that way <g>) , so my money’s on ProcessTamer now!

Just don’t go setting arbitrary processes to real time! You have been warned<g>

The Running instance of Windows Media Player

13
Filed under Media, MP3s, Office, Utilities

I’m finishing up my little Signature Enhancement Utility for Outlook and had finally gotten the Media Center 12 “Currently listening to” functions operational (This is just a minor feature I’ve seen popular on website blogs and forums, where the tag line contains not only the author’s name but what they are currently listening to, if anything, nifty and fun, but not in the least practical).

I figured I’d go ahead and try to support Windows Media Player 11 (and hopefully earlier versions) as well.

Basically, the idea is to grab a reference to the running instance, interrogate it as to the “playing” state and, if it’s playing or paused, retrieve the name, album, artist, etc info on the playing track and make it available as replaceable fields in the signature.

With Media Center, it was almost trivial:

Set omc = GetObject(, "MediaJukebox Application")
If not omc is nothing Then
   '---- it's running
   ' if it's not running, they can't be playing any music
   With omc
   Select Case .GetPlayback.State
      Case PLAYSTATE_PAUSED, PLAYSTATE_PLAYING
      '---- Media center info is available
      ps = .GetCurPlaylist.Position
      CurTrackTitle$ = .GetCurPlaylist.GetFile(ps).Name
      etc...

Obviously, if the GETOBJECT fails to return anything, Media Center isn’t currently running so the user can’t be listening to anything.

Three hours of Googling later, plus tons of experimentation and I’m not even an inch closer to getting this working for Media Player.

Using ROTView(the Running Object Table viewer, comes with various installations of Visual Studio), it does appear that WMP registers “something” with the ROT, which I’d think would be accessible by VB’s GetObject().

Alas, “Windows Media Player”, “WindowsMediaPlayer”, “MediaPlayer.MediaPlayer”, and on and on, all came up empty.

I scoured the registry for anything that even remotely looked like the moniker of a WMP registration with the ROT and everything I tried also came up empty. I’m sure it’s another case of knowing the magic password, but so far, it appears to be a tad more involved than Speak, friend, and enter.

So, for now, looks like I’ll have to rely on the FunPack for support of a limited set of attributes of the currently playing song in WMP. Apparently, for ITunes, you can use this plugin to accomplish the same thing, though I don’t use ITunes and probably won’t bother with testing that.

If anyone’s ever had any success with accessing the running instance of Media Player, I’d love to hear about it!

VB and Resource Files (Part 3)

1
Filed under Resource Files, Utilities, VB Feng Shui

In case you’ve missed the first 2 posts in this series, I’m discussing the concept of using Resouce files with Visual Basic 6.

In the first part, I talked about how to compile arbitrary information into a resource file and reference it from VB.

In Part 2, I discussed a technique for compiling a VersionInfo resource and writing it into your VB executable, thus replacing the incomplete VB provided VersionInfo resource.

In this installment, I wanted to share a little trick for defining the elements of the “Version number” in a resource (RC) file such that you only have to enter the version number once.

If you recall, I presented a sample RC file the last time, looking like this:

1 VERSIONINFO
FILEVERSION 1,2,3,4
PRODUCTVERSION 1,2,3,4
FILEOS 0x4
FILETYPE 0x1 //// 2 for dll, 1 for exe
{
BLOCK "StringFileInfo"
{
BLOCK "000004b0"
{
VALUE "CompanyName", "MyCompany"
VALUE "ProductName", "MyProduct"
VALUE "FileDescription", "MyFileDesc"
VALUE "LegalCopyright", "MyLegalCopyright"
VALUE "LegalTrademarks", "MyLegalTrademark"
VALUE "OriginalFilename", "MyOriginalFilename"
VALUE "ProductVersion", "1.2.3.4"
VALUE "FileVersion", "1.2.3.4"
VALUE "Comments", "MyComments"
VALUE "InternalName", "MyInternalName"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0000 0x04B0
}
}

If you’ll notice, there is one thing about this script that no lazy programmer worth a macro recorder would tolerate. The Version Number is duplicated several times, and what’s worse, in several different formats.

First, we have the FILEVERSION and PRODUCTVERSION entries, with comma separated numbers.

But then we also have the stringized version of those two elements, that must be specified as period separated elements within quotes.

I don’t have an alcohol fueled Code Sync 5000 robot to keep those numbers straight so I figured I’d just use macro substitution. Right. Turns out, the Resource compiler (RC.EXE) is a mighty fickel beast.

What I envisioned was a simple block to define the version number:

#define MAJOR          1
#define MINOR          0
#define REVISION       0
#define BUILD          116

and then use those definitions further down in the file, like so

FILEVERSION MAJOR,MINOR,REVISION,BUILD

and similiarly

VALUE “ProductVersion”, “MAJOR.MINOR.REVISION.BUILD”

But obviously, there’s a problem; actually, more than just one.

I won’t dwell on the details, but after much head scratching (polite euphimism), I ended up with this joyous concoction:

#define COMMAVER(mj,mn,rv,bl)        mj,##mn,##rv,##bl
// Commaver yields x,y,z,a  (necessary for the numeric versions)

#define PERIODVERPT2( mj )           #mj ""
#define PERIODVERPT3( mj,mn,rv,bl )  PERIODVERPT2( mj ) "." PERIODVERPT2( mn ) "." PERIODVERPT2( rv ) "." PERIODVERPT2( bl )
#define PERIODVER                    PERIODVERPT3( MAJOR,MINOR,REVISION,BUILD )
// PeriodVer yields x.y.z.a (necessary for the stringized versions)

// define the two numeric versions
// always make them the same                    
#define FILEVER        COMMAVER(MAJOR,MINOR,REVISION,BUILD)
#define PRODUCTVER     FILEVER

// define the two stringized version numbers, we just make them the same
#define STRFILEVER     PERIODVER
#define STRPRODUCTVER  PERIODVER

Then you can use them like so

....
FILEVERSION FILEVER
PRODUCTVERSION PRODUCTVER
....
VALUE "ProductVersion", STRPRODUCTVER
VALUE "FileVersion", STRFILEVER

Get clever with the #include directive and you can easily keep the version numbers of all the separately compiled VB components of your project synchronized and only have to set the version number in a single place.

If there’s a simpler way, I’d love to hear about it. But this works, and it keeps all my version numbers straight.

FIGlets

0
Filed under Utilities

How about a little fun?

I use batch files, make files, etc. to automate build processes quite often, but they can generate output that is, well, so very boring.

Why not liven it up a bit with FIGlets! This is some seriously old school tech, but it’s quite a nice effect if used in moderation.

Instead of just printing:

Build Starting...

in your output, how about:

      ____          __    ___ _____ __
     / __ )__ __(_)/ /___/ / / ___// /_____ ______/ /_(_)___  ____ 
    / __ // / / / / / __/ /\__ \ / __/ __ `/ ___/  __/ / __ \/ __ `
   / /_/ / /_/ / / / /_/ / ___/ / /_/ /_/ / /   / /_/ / / / / /_/ / _ _
  /_____/\__,_/_/_/\__,_/ /____/\__/\__,_/_/\__/_/_/ /_/ /_ \__, (_/_/_)
                                                           /____/

Makes it much more obvious when things have started or finished.

To generate one-off text snippets like this, go to The Ascii Generator.

or, for real flexibility, just download the original FIGlet command line utility. Be sure to get all the various fonts. Personally, I like the SLANT font the best (the example above is in SLANT).

Then you can just use:

FIGlet -f slant "Build Starting..."
....
FIGlet -f slant "Build Finished..."

in your batch files for some real early 90’s chic!

Visual Basic and line numbers

2
Filed under Utilities, VB Feng Shui

I’ve seen lots of rants over the years saying things along the lines of

Who wants to use a language that looks like this:

10   Print "Hello, World"
20   If x = 1 Then Goto 50
30   Print "Something else"
50   Print "Result was 50"

Or similiar nonsense. Of course, VB only vaguely resembles this style of code anymore, but one thing has remained virtually the same. Line numbers.

If I remember correctly, in BASCOM and BASICA, they were required. Then Basic Professional Developer System (MS BasicPDS) came out and line nums were no longer necessary, but you could still use them if you liked (probably more to be backwardly compatible with all that old BASICA code).

In all the older VBs (pre .NET days), you actually had to add line numbers to the source code itself in order to get them into the program and refer to them (via the ERL function). While this was certainly doable, the resultant code ended up looking like some seriously old-school mash you wouldn’t want to be caught dead delivering (or trying to maintain).

However, being able to report a line number during an error at runtime, at the client site, so it can be logged or reported back to you as a developer is damn near invaluable. Microsoft recognized this enough in .NET to include line number support built in to the error stack and handling subsystem (although the old style line numbers in code and ERL function still work, appearently).

That’s great for .NET, but there’s still a lot of VB6/5 and older code laying around that has to be maintained. So what do you do?

Ages ago, I built a little command line utility to run through every module in a VBP file (and every module of every project in a VBG file, too), and either add or remove line numbers. It output all the files to the same directory, but with “LINED_” prepended to the file name. This tactic makes it very easy to simply DEL LINED_*.* when you’ve compiled the line numbered project to clean things up and not leave line numbered code sitting around. You can run it against individual BAS, FRM, CTL, DSR, CLS, etc files, but if you point it at a VBP or a VBG file, it’ll even rewrite that file so that it’s contents point to the new file names. This makes it very easy to construct a batch file to 1) line number a project, 2) compile it, and 3) kill off the line numbered source files.

For instance, this batch file:

set pfile=%~dpn0
set pname=%~n0
set pdir=%~dp0
vbliner %pfile%.vbp
VB6.EXE /m "%pdir%LINED_%pname%.vbp"
del "%pdir%LINED_*.*"

Just name it the same name as a VBP file, save it to the same folder as your VBP file, and run it.

It will pull the file name and path from the name of the batch file itself (which should be the same as the VBP you want to compile), line number the project, compile it, then delete the line numbered source files when fnished, leaving you with a nice compiled file, completely line numbered but with none of the mess.

Its other nifty trick is to line number the lines using the same algorithm that the VB6 IDE uses to display line numbers as you move through code, as in:

This one trick (which I haven’t seen in any utility to line number VB source), makes it so that you don’t have to keep the line numbered source around so you can refer to it later. Somebody calls up saying they get an error in Module XYZ, line number 10202, all you have to do is pull that version of the module from SourceSafe (you do use version control of some kind, right?), load it up in VB and jump to the given line number. Can’t get much simpler.

VBLiner starts numbering at 10000, the rational behind that being that if you happen to need to include a hardcoded line number in your code for some reason, the automatic numbers hopefully won’t interfer with your hand coded numbers.

Another handy tip. Once you’ve opened your VB project, Right click the project explorer, select ADD, then ADD FILE. Find the BAT file that you just created above, and be sure and check the “Add as Related Document” box before adding it to your project. Now, then, you should be able to simply DBL CLICK on the BAT file from the VB project explorer to run the bat file and compile your project, complete with line numbers, all automatically.

And a final note; VBLiner does ostensibly support removing line numbers from VB files as well, but I’ve never had much use for that facility, so it’s not well tested. As with any freeware, use at your own risk. And it should go without saying, Back up your source files before running it on them.

Download a zip of the utility here and let me know what you think.

VB Swiss Army Knife

7
Filed under Utilities, VB Feng Shui

VB has one of the best IDE’s around. Sure Eclipse is pretty capable, Delphi is quite slick, and for the purists, editors like SlickEdit can make you almost believe you’re coding in an IDE.

But VB’s IDE is the one to beat. And it has been since VB3.

But even the best have issues; mistakes, ommisions, things that jsut could have been so much better.

And that’s where MZTools comes in.

If you haven’t already played with it, download a copy and install it now. Carlos originally built MZTools for VB6 way back when, and that version was (and still is) a free utility. He’s branched out to supporting Visual Studio .NET now, and the newest version is not free, but it is worth every penny.

Take a look at the features page for version 3 (which supports VB6). The Code Review, Code Templates, and Error Handler Templates are gauranteed to save tons of time.

Personally, I don’t like his line numbering support. I feel like the line number applied to a line should be the same as the actual line number in the file, as reported by the VB6 editor, like this:

That way, you don’t have to retain the numbered version of the source to be able to refer back to a specific line number. However, this is a pretty minor nitpick.

In short, MZTools is a massively handy utility to have on you’re VB menu bar. Definitely for VB6 (cause it’s, well, free), and worthy of consideration for .NET.

Outlook Signatures

2
Filed under Office, Utilities

On a lark a few days ago, I decided I’d like to have random rotating quotes appended to my outgoing emails. I use GMail for mail preview (and access when I’m away from my desk), but usually, I use Outlook when I’m at my desk.

Supporting random email signatures in GMail is a topic for another day, and I’ve honestly not even investigated it at all.

But Outlook. Surely, I thought there must be a free little utility to do that out there.

Well there are a few, but most aren’t free, and the few that are, aren’t particularly well built from what I can tell.

The one free one I did see that seemed to hold promise was QLiner. After a quick install, and then converting some quotes to a plaintext file, I fired it up and set things up.

It works, but it seems finicky to me. For one, it doesn’t actually template out the signature, so much as it completely replaces the existing signature with a rebuilt version (with the new quote) on a configurable timeout. So if you sent 3 messages within 5 minutes, and the timeout was set to 10 minutes, it’s likely all 3 messages will have the same quote.

Plus, it seemed to just “stop working” after a time. I never could see a pattern to this, but, invariably, after a few days, I’d notice that the signature wasn’t changing anymore. Stopping and restarting the program fixed it each time, but that’s not the hallmark of a solid app.

In the end, I uninstalled it, and I believe I’m going to throw my hat in the ring on this one.

I’m calling it Sig-Licious. The idea is that it is a simple COM Outlook addin that monitors for new email creation events, intercepts it, and parses and replaces keywords in the signature with specific bits of info.

For instance, {Date}, {Quote}, {QuoteAuthor}, {CurrentTrack} (ie what piece of music you’re listening to right now, if any), etc, etc.

Any thoughts on what other variables might be nice? To totally geek it up, how bout any ol’ Environment Var? Or the content of a performance counter at the time? Or maybe your CPU fan speed? I’m thinking various Active Directory fields might be nice, if available. Or maybe info from arbitrary Text files? Or maybe info from arbitrary posts you store in specific folders within Outlook proper.

I’ll post something when I’ve got it a bit farther than just messageboxes<g>.

Or stop me before I get too far and tell me the URL of that nifty app you’ve found that can do all this. Please!

Update

I found a few more apps out there for this. First, ADOLSign is 129$! For what is essentially a search and replace tool. Jeez.

Then there’s Exclaimer. It’s even more expensive, but does a lot more. For an enterprise setup, I could see spending a few bucks for this sort of functionality, but for your average joe, like me? Um, no.

I also just ran across Symprex Mail Signature Manager. It’s freakin’ expensive and you can only get a min 10 user license, and it appears to require Echange, but if you need something like that, it looks pretty complete.

And finally, Bells and Whistles. It’s also basically a glorified macro search and replace. 29$. Better, but still, 29$ for this?

So far, nothing for the loan gunman looking for nifty sigs. I think I’ll continue on with my little addin.

Icon Editors

2
Filed under Icons, Utilities

I had to do some icon editing recently, and did a little digging for a decent, free (or nearly free) editor that supports the new Vista and XP style icons.

I turned up AWIcons lite that looks pretty good, for a freeware version of their pro app.

Then I happened upon IconFX. Wow! It’s not quite as polished and it’s missing a few minor features, but it’s a pretty slick package.

I also looked at Axialis and IconCool, but both are commercial and in the 50-60$ range, which isn’t bad, but still.

In the end, I like AWIcons for the UI and the ability to sort the icon images within a single icon to the order necessary for XP. It’s an SDI app (meaning you can only open one icon at a time in the app), but you can open multiple instances of the app, and cut/paste works seemlessly between them, so it’s not a deal breaker.

IconFX supports more effects, hue, saturation, plus drop shadow etc, but you can’t reorder the internal images. It is MDI, though, so you can load up any number of icons simultaneously to edit. The UI is a bit clunkier, but still perfectly functional.

There’s a very good writeup of a number of the better editors here. To summarize, they recommend Axialis, followed by MicroAngelo, AWIcons and IconCool. Personally, I ran into errors after installing IconCool, so I’m not so sure about that one.

Looks like there’s hundreds more, but these seem like the most capable. Anybody know of others that are good?