Friday, March 17, 2017

Ten Years On

Just realized I've had this blog up on Blogger since February 2007.

My site is now hosted on GitHub pages at

See you there!

Sunday, March 5, 2017

Control+Shift+Enter to launch a Windows program as admin!

To launch any Windows program with elevated (admin) privileges, hold Control+Shift keys, then double-click the program's icon, even on the taskbar.

Alternatively, hit the Windows key, type the program name, e.g. cmd then type Control+Shift+Enter to launch the program with elevated (admin) privileges. You might have to enter admin credentials in the UAC popup.

See this LifeHacker article for more details.

Wednesday, April 13, 2016

How to check for admin rights from a Windows batch file

Simple check for administrative permissions in a batch file:

REM Check for admin rights - net session must run as admin
net session >nul 2>&1
if %ErrorLevel% NEQ 0 (
    echo You must right-click and select "RUN AS ADMINISTRATOR" to run this script.
    exit /B

Wednesday, February 17, 2016

Another HEREDOC style for Windows Batch Files

I wanted to pipe a SQL query to sqlplus in a batch file, without using a temp SQL file.

That technique involves echo'ing the SQL statements to a temp file, then call sqlplus on that file:

REM create the temp SQL file
echo SELECT USER >>temp.sql
echo FROM DUAL;  >>temp.sql

REM execute sqlplus
sqlplus -S / @temp.sql

REM cleanup!
del temp.sql

An alternative is to wrap the echo statements in parentheses "( ... )", so they execute as a block, then pipe "|" the result to sqlplus:

    echo SELECT USER
    echo FROM DUAL;
) | sqlplus -S /

Admittedly, this is not much prettier than the first example, but it's self-contained, and doesn't leave random temp files that may or may not get cleaned up.

Tuesday, February 24, 2015

Perl property method?

package Foo

sub new

# bar property
sub bar
    my ($self, $text) = @_;
    if ($text)
        $self->{bar} = $text;
        return $self->{bar};


my $foo = Foo->new;

$foo->bar; # returns value of $self->bar
$foo->bar("baz"); # sets $self->bar = "baz"

Friday, May 9, 2014

HEREDOC for Windows Batch Files

From Wikipedia: "In computer science, a here document (here-document, heredoc, hereis, here-string or here-script) is a file literal or input stream literal: it is a section of a source code file that is treated as if it were a separate file."

Here's one way to accomplish this in a Windows batch file. Inside the batch file, echo the text to an output redirection, e.g. "> here.txt". Use carets "^" followed by double linebreaks to output on separate lines:


echo This is my ^

multi-line here document ^

that this batch file ^

will print! > here.txt

When executed here_text.bat will create a new file here.txt containing the lines of text:

This is my
multi-line here document
that this batch file
will print!

Monday, March 3, 2014


Noticed this rather defensive SSID in passing from my bus commute. I'm not sure if it's the WiFi or the Wife that's under guard, but the security's pretty robust.