Sunday, October 19, 2008

Reactivating Dynamic Drives for Windows XP Professional

Requires: Windows XP Professional and optionally Ruby, AutoIt

Here's a quick thing that I learned and set up. First, the problem. I frequently use a usb external hard drive at home. As a dynamic disk, everytime I plugged the hard drive in I had to right click my computer, select manage, select disk management, select my external hard drive, and reactivate the disk. Or (after I removed the "My Computer" icon from my desktop) control panel->administrative tools->computer management->disk management->external drive->reactivate disk. It's not too much of a hassle, but it is stupidly annoying to have to go through that sequence often. If you have multiple disks that you want to manually individually activate, always have certain dynamic drives plugged in and want them activated at startup, or (like me) you just don't want to touch the mouse if there's another way, then you'd want a way to automate this process. So I found a way to avoid all the mindless clicking.

It's not really anything new. It's just making use of the diskpart command line utility. Here's documentation on diskpart. I wrote a small ruby script to run the diskpart for me. You can use a static batch script and text file to do this as well. In my actual implementation, I have a different ruby script that makes sure I'm activating the "right" disk. But this sample solution will always activate disk 1:
activateDynamicDisk.rb
view plaincopy to clipboardprint?
  1. require 'win32ole'  
  2. f = File.new"online.txt""w" )  
  3. f.print( "select disk 1\n" )  
  4. f.print( "online\n" )  
  5. f.close  
  6. au3 = WIN32OLE.new("AutoItX3.Control")  
  7. au3.Run( "diskpart /s c:\online.txt" )  
  8. File.delete( "online.txt" )  
Really easy, eh? You can easily set it up to run every time windows boots up. I should also mention dynamic drives only work with Windows XP Pro, so my external drive is unusable with a home edition. Now, the next trick is figuring out how to run this script whenever I plug the device in. I wonder how that's done.

Wednesday, October 15, 2008

Requirements for Tweaks

On this blog, I'm going to occasionally talk about tweaks I make to my machines (of various OSes.) When I say tweak, I mean a special configuration or short script to make my computer more suited to my needs. So basically a hack, but without the bad connotation people give the word "hack" nowadays.

As I've been reinstalling machines, I've been making notes about what I do to them and thought it would be useful to have an easy to find reference online, so I'll be posting cleaned up versions of these notes. Each tweak requires a certain environment (OS and programs), so I'm going to go over the common requirements in depth in this post. That way, when I reference a program, I'll just link here. I'll add to the following list as needed. Here's the list so far:

Windows XP Professional (SP2/SP3) - This is one of Microsoft's Windows Operating System (OS) versions. I'll leave it up to you to figure out how to get the OS and how to install it. XP Professional is different than XP Home, so the tweaks I describe may not be compatable with both. I use Professional myself and don't have access to a Home machine to test things on.

Windows Vista Ultimate - This is one of Microsoft's Windows Operating System (OS) versions. It's newer than XP. I'll leave it up to you to figure out how to get the OS and how to install it. Vista is different than XP, but many of the tweaks I describe should be compatable with both. The only version I have access to is Ultimate.

Solaris 10 - This is one of Sun's Solaris Operating System (OS) versions. It is UNIX based and is notably different from previous versions due to its zones. This is one of the Operating Systems I use most at work.

AutoIt - Auto It is a freeware automation language for Windows. It allows you to easily simulate a windows user with a script... you can send key presses or text to any windoe application. AutoIt scripts end with au3. AutoDownload an installer from http://www.autoitscript.com/autoit3/

PS Hot Launch - PS Hot Launch is a Windows program that allows you to map keyboard shortcuts to files. Invoking the keyboard shortcut will execute the file specified. For example, you can make ctrl-win-w open microsoft word and win-v open your winamp. Using too many of these is not a good idea because you'll probably start running into conflicts. But for a few applications, this program can work wonders. Play around with it. Download this from: http://www.pssoftlab.com/pshl_info.phtml

Ruby - Ruby is a dynamic, reflective, general purpose object-oriented programming language. It's a scripting language very much like Perl. Ruby scripts end with either rb or rbw (windowless). In order to run ruby scripts, you need the Ruby VM. You can download it from http://www.ruby-lang.org. There are installers for all of the popular Operating Systems under downloads. Once you've installed ruby, add the fxruby gem by running "gem install fxruby" in a command/terminal prompt. Fxruby is what I use for GUIs.

Batch Files - A batch file is a Windows text file, with the extension .bat or .cmd, containing a series of commands intended to be executed by the command interpreter. When a batch file is run, the shell program (usually COMMAND.COM or cmd.exe) reads the file and executes its commands, normally line-by-line. A batch file is analogous to a shell script in Unix-like operating systems. When working in windows, it's very useful knowing how to batch script as it allows you to lots of automation.

Sunday, October 12, 2008

Creating Windows Icons

So I'm writing a Windows C# application (I'll talk about it later) and I wanted to use my own icon for it. I needed a .ico image, Visual Studio wouldn't let me use any other image file types. I usually use Adobe Photoshop for my editing, but that program doesn't support natively icons. I found a Photoshop plugin for icon files at this website and it worked perfectly. There was no hassle at all.

I created a 16x16 icon and added it to all my forms easily. I set the icon to be used as the default icon through the project properties (under the application submenu) and that worked perfectly too. I'm really happy with how it turned out.

This post was really just to give out the link to the website for the photoshop icon plugin. Oh yeah, I'm probably going to be posting a good deal of C# stuff for a while since I've been playing with it a lot recently. Just some fair warning...

Sunday, October 05, 2008

Virii and XP Royale

Yeesh, it's been a long time since I posted here. Like just about everyone, I'm pretty busy... but the "busy-ness" gives me some good things to write about. So I'll be posting a lot more regularly for a while.

The most recent "busy-ness" was a full reinstallation of one of my desktop computers. It wasn't something that I really planned to do... I ended up catching a virus while testing google adsense (some ringtone ad) with an Internet Explorer 5 browser. I wasn't being that careful on that machine, since I didn't really didn't expect to catch anything through adsense links. It was a serious virus too. Like most of them, it put a bunch of adware on the machine (which would pop up sporadically), but it also tried to add some fetching programs and some dll files. Nasty, nasty... anyways, I didn't entirely trust that the anitvirus on the machine was able to catch everything, so I decided to wipe the whole harddrive (I used Active@KillDisk) and reinstall. I put on Windows XP Professional SP3 instead of Vista and went through the process of configuring the machine to my needs. It kinda needed to be done anyway, the machine was getting cluttered and I didn't lose any data since it's not a machine I really use for anything important.

One nice thing I found while reinstalling was the Windows XP Royale Noir theme. I like its look better than Windows Vista. It's a really sleek, black XP theme that I read the developers never fully released. Someone got a hold of it and finished it up, then made it available. I liked it so much I switched my main desktop computer to the theme... even though I'm pretty sure it makes the machine run slower.

Download and check out the theme here: http://www.softpedia.com/get/Desktop-Enhancements/Themes/Royale-Noir-Theme.shtml

To use the theme, you will need patch your uxtheme dll by running this program: http://www.softpedia.com/get/System/OS-Enhancements/UXTheme-MultiPatcher.shtml