Disabling UAC Prompt for Cygwin run.exe in Windows 7

So, every time I try to start Cygwin (actually, the cygwin XWin server) I get that ugly UAC prompt. Very annoying since this is an application I use quite frequently. Unfortunately, changing the properties to always “Run As Administrator” does not fix it.

The only way I’ve successfully managed to get it to work is through the Application Compatibility Toolkit from the Microsoft Download center.

Download and install the Application Compatibility Toolkit.

Once installed, run ACT as administrator. Right click on its menu entry while holding the Shift key and select Run as Administrator. Note that you have to run the correct version for the architecture of the target program. For instance, Cygwin is 32-bit so the 32-bit version of ACT must be used.

Application Compatibility Toolkit

This will open up a new custom database that we will edit. From here click the Fix icon in the toolbar.

Application Compatibility Toolkit

In the Create new Application Fix dialog, give it a name, the vendor is optional, and select the path to the executable. The executable we want is run.exe on my machine at C:\cygwin\bin\run.exe.

Create new Application Fix

Click next, and next again. From the Compatibility Fixes list, select “RunAsInvoker” and click Finish.

Create new Application Fix

Next save the database by clicking the save icon. You will be prompted to provide a name.

Database Name

Once it is saved we have to install it. Right click on the database in the tree and select Install.

Application Compatibility Toolkit

Installed dialog

Now you should be able to click the Cygwin XWin Server icon and it will start without prompting you. One additional issue I had was that before any of this I had created a Quick Launch icon for the XWin Server. For some reason, these changes do not take affect right away for the Quick Launch icon only. I had to delete and recreate the Quick Launch icon before I could start it that way without being prompted.

Tags: , , , , , ,

Tuesday, January 22nd, 2013 Tips and Tricks No Comments

Managing MinGW packages with mingw-get

This isn’t meant to be a comprehensive tutorial on everything you can do with mingw-get but rather a place for me to document some tips that I found Googling and felt I should consolidate here. If something here does not work for you or if you have some other useful pointers let me know and I’ll update this post.

MinGW is standard equipment on any new Windows computer I need to use which includes most of the tools I use regularly. I had a need to create zip files recently however zip and unzip are not included in the base MinGW installation. The easiest way to install these utilities is through mingw-get.

$ mingw-get install msys-zip
$ mingw-get install msys-unzip

This lead me to the question, what additional packages are actually available this way? Cygwin provides a nice GUI to pick and choose packages and of course there are the various package managers available for the many Linux distros. There doesn’t seem to be an easy way to list packages that can be installed with mingw-get. One method I found is to look in the catalog file.

$ grep "package name" /mingw/var/lib/mingw-get/data/*.xml

Or to make the output a little nicer:

$ grep "package name=" /mingw/var/lib/mingw-get/data/*.xml |
    sed 's/.*package name="\([^\"]*\)".*/\1/'

These commands will show you all the packages available whether they are already installed or not. To list packages that are already installed there is a nifty little script that can be found here. Download mingw-get-info and copy it to /mingw/bin.

$ mingw-get-info installed

This script is not an official MinGW tool and seems to only exist as an attachment to the linked bug report. From the comments on that page the script will generate a number of reports:

$ mingw-get-info all

to see current status for all available packages,

$ mingw-get-info installed

to filter on only those packages which are installed locally, or

$ mingw-get-info index

to see an index for the repository catalogue.

Tags: , , , , , ,

Friday, January 4th, 2013 Programming, Tips and Tricks 1 Comment

OpenGL Globe Screensaver (Update)

I’ve been running this OpenGL Globe screensaver I wrote for several years now on various machines without any issues. Until the other night when I installed it on my new laptop.

So I did a little digging and figured out what was going on. After I installed the screensaver and tried to activate it I got the following error:

LoadLibrary failed with error 1114: A dynamic link library (DLL) initialization routine failed.

Googling for information brought me to this site. Further down in the discussion they start talking about switchable graphics with the AMD drivers (which I have) and the Catalyst control center. It seems that by default screensavers are run in “Power Saving” mode with hardware acceleration disabled. Well, since this is an OpenGL screensaver that just will not do!

I open up the Catalyst control center and it’s not listed in the recent applications. I guess since it hadn’t run yet it wouldn’t show up. Of course, the Browse… button on the Other Applications box below won’t allow you to select a .scr file. So I try right clicking the .scr file to try to test it that way:

Explorer context menu | Test

Hey, it starts! So I jump back into the Control Center and there it is!

Catalyst Control Center

I set it to “High Performance” and go back to the screensaver control panel and it starts right up!

Interesting. I’m not sure if or how I could update the installer to detect and adjust these settings automatically. I’ve been running this screensaver (or previous builds of it) on various computers for several years now and this is the first time I’ve encountered an issue with it. I’m not sure if I can even consider it an issue with the screensaver or not though I’d argue either the screensaver or the installer need to be updated since I can’t really expect end users to have to jump through hoops to get my software to work.

I’m probably not going to do it any time soon however. If you have an idea for fixing this problem in an automated fashion I’d be interested in hearing it. If you’d like to play around with the installer code let me know and I’ll give it to you.

In the mean time, if you see this issue, let me know if this fixes it.

Update 3/12/2013

So, I’ve been playing around with the drivers and mucked things up enough that I had to revert. However, when I installed the original version and encountered the same problem with the screensaver described above, the above fix did not work this time! Grrr…

To get around it I had to go in and manually add it in the registry. One of the existing screensavers that actually ran without issues was listed in the Switchable Graphics dialog as shown above. I picked ribbons.scr. I opened regedit32.exe and searched for “ribbons.scr”.

Registry Editor

I edited this string value and changed the path to specify “ssglobe.scr” instead of “ribbons.scr”. When I reopened the Switchable Graphics dialog it was listed though it was marked as “Not Assigned”. I’m sure there are other registry settings that can be updated to add it and give it the proper settings all in one shot. However, getting it to show up in the dialog is sufficient for now as the settings can then be changed from there. I set it back to “High Performance” and all is again working.

Further reading:

Tags: , , , , , , , ,

Thursday, December 6th, 2012 Graphics, OpenGL, Tips and Tricks 2 Comments

Determine if a value is an option in a select element with jQuery

To determine if an html select box contains a given value as an option, in jQuery you can try to select the option and see if it exists:

if($("#id option[value='someval']").length != 0)
{
   // it exists!
}

That’s it! Have fun!

Recommended reading:

Tags: , , , , ,

Friday, November 9th, 2012 JavaScript, Programming No Comments

Disable the Fn + Function Key combo to the use the function keys on HP laptops

Some genius at HP decided the function keys F1 through F12 aren’t important enough and demoted them to second level functions. To access them you now need to pres the Fn + Function key combination to get the normal behavior. The default behavior for those keys now is what you would normally have had to hold the Fn key to access. Like turning your wireless card on and off, adjusting the display brightness, etc… F5 it looks like enables/disables the backlight on my keyboard.

Um no. Setting the display brightness does NOT need to be a top level function, idiot! I’ll set it once and never touch it again. In the mean time, F3 is used all the time for opening Find/Replace dialogs. I use F5 all the time to refresh web pages, folders, my IDE, etc. I can handle holding the Fn key to toggle my wireless on and off or changing display outputs. In the mean time I want my function keys back.

The fix isn’t a simple control panel setting either. You actually have to go into the computer BIOS to change it.

When the computer boots you have to hit F10 to enter the BIOS settings. (Remember to hold the Fn key or you might just be trying to eject your CD-ROM). Once at the BIOS menu navigate to the “System Configuration” settings. Select “Action Keys Mode” and turn that crap off.

Reboot and your sanity and balance in the universe will have been restored.

Tags: , , , ,

Sunday, October 21st, 2012 Tips and Tricks No Comments

Java – Failed to download required installation files

Oracle, you’ve outdone yourself! Still not getting this consumer level software thing are you?

I got a call at work that my daughter’s laptop was acting funny. Turns out she got hit by a virus. I have her user account set up to run with limited permissions so there wasn’t any real damage and was fairly easy to clean up.

I spent some time trying to figure out how she got infected in the first place since she doesn’t usually venture too far from her game sites, doesn’t have email or facebook, and is pretty closely monitored by us. Her internet history didn’t show anything I didn’t expect, the typical game sites, Google searches for Justin Bieber, etc…

Nothing was out of the ordinary however, some of her game sites make heavy use of Java. Maybe a rogue ad took advantage of the recent Java exploit or something. No, she has Java 6 installed so it wasn’t that particular exploit. I’m not entirely sure it was a Java vulnerability, just covering bases here. Maybe something else?

I figure I’d make sure it was updated anyway and started the Java control panel. Went to the Update tab and clicked Update Now. A new version was available so I clicked Install. The prompt for my administrator password came up (of course, she’s running a limited user account). I enter it and the following error pops up:

Failed to download required installation files.

Hmmm… ok. Not sure why. I check the network settings and tell it to use a direct connection instead of my default browser settings. Same issue.

Maybe it’s a permission issue. So I navigate in Explorer to the Java directory, find the javacpl.exe file, right-click and select Run as administrator... Enter my password and try again. Same issue.

I switch user and log into my administrator account. Open the Java control panel and try again. Voila! It works!

Looking around the internet, this bug has been around for quite a while and still isn’t fixed. It seems the Java updater won’t work at all unless you are logged into the administrator account. Being a general user and running it as administrator is NOT sufficient. Grrrr…

Tags: , , , , , ,

Tuesday, September 11th, 2012 Tips and Tricks 1 Comment

Creating New Folder in Windows Explorer

Here’s one I forget every so often. What hot key combination will let you create a new folder in Windows Explorer?

In all versions of Windows, with a folder opened in Windows Explorer use Alt + F, W, F. This basically walks you through keyboard navigation of the Explorer menu.

Windows 7 has added a hot key combination specifically for this task. Ctrl + Shift + N

Thanks to How-To Geek for the tip!

Tags: , , , , ,

Tuesday, July 10th, 2012 Tips and Tricks No Comments

Remove Drive Letter for Encrypted Partition

I created a TrueCrypt partition on my machine that is assigned a letter when mounted through TrueCrypt. Through this drive letter TrueCrypt gives access to the files as if they were on any other drive, performing the encryption and decryption behind the scenes.

However, the encrypted partition itself is also recognized by windows and is given its own drive letter. Windows sees the partition and thinks it is unformatted and gives you the option to format it. I’d rather this “unformatted” partition not show up in Windows Explorer at all. To get rid of this drive letter do the following:

(This is for Windows XP. Vista and Windows 7 may be slightly different. If they are VERY different, email me or leave a comment with the correct procedure and I’ll update this post.)

  1. Right-click “My Computer” and select Manage.
  2. Select “Disk Management”.
  3. Right-click the encrypted partitionand select “Change Drive Letter and Paths…”
  4. Click Remove.
  5. Click Yes to confirm.

Further reading:

Tags: , , , ,

Saturday, July 7th, 2012 Security, Tips and Tricks No Comments

java XML parsing: line 1, character 38, unable to switch the encoding

While working on a Java web application I was trying to import an XML file into a Microsoft SQL Server database table with an XML type column. Everything seemed to be OK except I was running into the following error:

java XML parsing: line 1, character 38, unable to switch the encoding

After much googling the consensus was that this error is raised because SQL Server stores XML in the XML type column using UTF-16 character encoding while the file I was trying to insert was UTF-8 encoded. So, I had to convert my input data from UTF-8 to UTF-16.

My original code was doing this:

String str = new String(data);

The String class defaults to UTF-16 unless specified otherwise. However, to be sure I changed the above to:

String str = new String(data, "UTF-16");

Nope, didn’t work… Well, the documentation for the String constructor isn’t the greatest so maybe the encoding parameter is just used as a hint at what the input data is supposed to be. The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. Not entirely clear… Just to be sure, I changed it to this:

String str = new String(data);
str = new String(str.getBytes("UTF-16"), "UTF-16");

Still no luck. Ok, how about using CharsetEncoder/Decoder

Charset utf8= Charset.forName("UTF-8");
Charset utf16= Charset.forName("UTF-16");

CharBuffer cb = utf8.decode(new ByteBuffer.wrap(data));

ByteBuffer outputBuffer = utf16.encode(cb);

String str = new String(outputBuffer.array(), "UTF-16");

Still no.

Well, looking at the XML document itself I see the XML declaration is specifying the encoding attribute as encoding="UTF-8". I delete it and finally it works.

So, even though I changed the input to the correct encoding, the fact that this attribute was specified in the XML document itself caused SQL Server to complain. Ok fine… However, I ended up removing all the encoding conversion code that I had been playing with and reverted back to the original code:

String str = new String(data);

Tried the import again but without the encoding attribute and it still works. SQL server will do the conversion for you if the encoding attribute isn’t specified. It won’t touch it however if it is.

So, options now are, 1) either remove the encoding attribute altogether, or 2) make sure the file is UTF-16 encoded with the encoding attribute set accordingly.

Related links:

Tags: , , , , , , , ,

Saturday, July 7th, 2012 Database, Java, Programming, SQL Server No Comments

Facebook Fail!

It seems someone at Facebook has broken the BigPipe. Currently, the site is broken for me on both Firefox and IE8. Looks like this problem has been around for a while. Something seems to get screwed up client side but I can’t tell what. Clearing the cache and other temporary data doesn’t seem to fix it. So far, the only thing that seems to work is to reboot the machine.

Tags: , , , ,

Thursday, July 5th, 2012 Uncategorized No Comments