Archive

Archive for November, 2012

Migrating My GWB Blog Over To WordPress

November 20th, 2012 3 comments

Geeks With Blogs has been good to me, but there are too many tempting things about Word Press for me to stay with GWB.  Particularly their statistics features, and also I like that I can apply specific tags to my posts to make them easier to find in Google (and I never was able to get categories working on GWB).

The one thing I don’t like about WordPress is I can’t seem to find a theme that stretches the Content area to take up the rest of the space on wide resolutions…..hopefully I’ll be able to overcome that obstacle soon though.

For those who are curious as to how I actually moved all of my posts across, I ended up just using Live Writer to open my GWB posts, and then just changed it to publish to my WordPress blog.  This was fairly painless, but with my 27 posts it took probably about 2 hours of manual effort to do.  Most of the time WordPress was automatically able to copy the images over, but sometimes I had to save the pics from my GWB posts and then re-add them in Live Writer to my WordPress post.  I found another developers automated solution (in alpha mode), but opted to do it manually since I wanted to manually specify Categories and Tags on each post anyways.  The one thing I still have left to do is move the worthwhile comments across from the GWB posts to the new WordPress posts.

The largest pain point was that with GWB I was using the Code Snippet Plugin for Live Writer for my source code snippets, and when they got transferred over to WordPress they looked horrible.  So I ended up finding a new Live Writer plugin called SyntaxHighlighter that looks even nicer on my posts Smile

If anybody knows of a nice WordPress theme that stretches the content area to fit the width of the screen, please let me know.  All of the themes I’ve found seem to have a max width set on them, so I end up with much wasted space on the left and right sides.  Since I post lots of code snippets, the more horizontal space the better!

Get AutoHotkey Script To Run As Admin At Startup

November 6th, 2012 4 comments

<Update>Before you go running your script as an admin, see if this less obtrusive fix will solve your problems.</Update>

A few weeks back I posted some problems with running AutoHotkey (AHK) in Windows 8, and that the solution was to run your AHK script as admin.  I also showed how to have the script start automatically when you logged into Windows.  What I didn’t realize at the time though was that the method only worked for launching my AHK script as an admin because I had disabled UAC in the registry (which prevents most Metro apps from working in Windows 8, and likely isn’t acceptable for most people).

So here is a Windows 8, UAC-friendly method to automatically launch your AHK scripts as admin at startup (also works in previous versions of Windows).  The trick is to use the Task Scheduler:

1. Open the Task Scheduler (also known as “Schedule tasks” in Windows 8 Settings).

Open Task Scheduler

2. Create a new Basic Task.

3. Give it a name and description (something like “launch AutoHotkey script at login”), and then specify to have it run “When I log on”.  Then specify that you want it to “Start a program”, and then point it towards your AutoHotkey script.  Before you finish the wizard, check off “Open the Properties dialog for this task when I click Finish”.

Create Basic Task in Task Scheduler

4. When that Properties dialog opens up, go to the Conditions tab and make sure none of the checkboxes under the Power category are checked off; this will ensure the script still launches if you are on a laptop and not plugged into AC power.

Basic Task Conditions

5. Now here is the important part; To have your script “Run as admin”, on the General tab check off “Run with highest privileges”.

Run Scheduled Task as Admin_thumb[3]

Now your AHK script should start automatically as soon as you log into Windows; even when UAC is enabled Smile

6. If your AHK script uses an #Include statement to include other files, you may get an error similar to this one when your task runs:

“#Include file … cannot be opened. The program will exit.”

AHK Cannot Open Include File

The solution to this is to tell your AHK script to start in the same directory as the file that you want to include.  So you will need to edit your scheduled task’s Action to specify the Start In directory.

Task Scheduler Start In Directory

Happy coding!

==< EDIT >==

What I failed to realize earlier was that by default the Task Scheduler runs it’s programs in non-interactive mode, so they may run as the correct user, but in a different user session.  Since most AHK scripts are interactive (i.e. they respond to user input), this means that your script may not work exactly as it should all of the time.  For example, my AHK scripts were not able to launch ClickOnce applications.

The fix is to create your Scheduled Task in interactive mode.  Unfortunately you cannot do this through the GUI; it must be done through the command line.  So if you open up a command prompt you can use the following command to create a new interactive scheduled task:

schtasks /Create /RU "[Domain][Username]" /SC ONLOGON /TN "[Task Name]" /TR "[Path to program to run]" /IT /V1

for example:

schtasks /Create /RU "Dan Schroeder" /SC ONLOGON /TN "Launch AHK Command Picker" /TR "D:AHKStuffAHKCommandPicker.ahk" /IT /V1

The /IT switch is what tells it to create the task in Interactive mode.  The /V1 switch actually specifies to create the task as a Windows XP/2000/Server 2003 compatible task, and has the added benefit of making the task run as admin by default with the Start In directory specified as the directory holding the file to run (i.e. steps 5 and 6 above; you will still need to do step 4 though).

If you already have your Scheduled Task created, you can simply make it interactive with the command:

schtasks /Change /TN “[Task Name]” /IT

I hope you find this as helpful as I did!

==</ EDIT >==