AdSense Top


VBS to the rescue

Another interesting day at work.  I finished updating our warranty information in our Asset Database pretty quickly, so I had most of the day to do whatever I wanted.  I had heard when I was first hired that we had gotten a new exchange server, and that I would have to go around to everyone's computers, see what PST files they had open, close them, move them to the new server, and re-open them.  Manually.  Bunk that, time to put my title of Master Problem Solver to work.

After a few quick searches online, I had a script that mapped out all PST files on the drives you fed it, and recorded their locations in a logfile.  Good place to start, since I didn't have any experience writing logfiles with VBS, let alone looping over a filesystem.  After tweaking that a little bit I had a script that copied the files it found to a location I fed it (which would later be hardcoded/dynamically generated based on the login name).  Awesome.  After doing some research on opening/closing PST files with VBS (which yielded almost nothing related to it), I decided to simply try and open a .lnk that pointed to a PST file in Outlook.  Fortunately, it was smart and followed the link, so I decided that instead of setting Outlook to open the new file in my script, I would try replacing the old copy with a shortcut to the new one and fool it into re-assigning it.  As you might guess, this didn't work so well.

Outlook was looking for a .pst file, and not a .lnk file (which I was afraid of), so the open PST files now returned an error that it could not be found.  At this point I figured alright, time to take a break and when I come back if I had an epiphany roll with it, and if not work on grabbing the login name for use later.  No such Epiphany, so I moved on to the name.  Searching for these led me to an already completed VB script that read the currently open PST locations from Outlook, determined if they were local or not (if they weren't it skipped them), recorded the locations, closed them, copied the local ones to their \\server\home folder, and re-mapped them in Outlook.  Essentially, it does exactly what I was looking for, and with a few modifications it's able to run just fine and do exactly what I need it to.

Moral of the story:  learn how to search better, because somebody already invented the wheel.  If you're interested in the actual script I'll post it up, just let me know.  I don't have access to it right now (it's at work, I'm not, and VPN access is given out sparingly) otherwise I would throw it up for the world to see now.

No comments:

Post a Comment