windows net user add password with special characters

The command line to add a local windows user called “newuser” with the password “p&ssw^rd”

You try

net user newuser p&ssw^rd /ADD

Uh-oh – it fails!

C:\> net user newuser p&ssw^rd /ADD
The user name could not be found.

More help is available by typing NET HELPMSG 2221.

'sswrd' is not recognized as an internal or external command,
operable program or batch file.

If the password contains certain special characters – like an ampersand “&” or a caret “^”, the password will be garbled, broken, butchered.

One solution is to have it prompt for the password

net user newuser * /ADD

but if you are scripting, this isn’t really helpful.

No, you cannot use quotes.

The solution: All Ampersands must be escaped with a caret “^”, and all carets in the password must be similarly escaped.

UPDATE: turns out in more recent versions of windows, exclamation marks “!” must also be escape with two carets.
See here for a good list of how to escape things.

So, to use the password p&ssw^rd in a command line, you would need to replace it with p^&ssw^^rd

net user newuser p^&ssw^^rd /ADD

This will do what you expect

Note that if you do not escape the carets, the command may succeed, but the password will be wrong.

Installing Windows Identity Foundation 3.5 in Azure Role Startup Task (Server 2012 VM)

The new VMs used by Azure are Server 2012+, and you cannot use the msu installer for WIF (Like you could here:

You must use dism to enable the feature.

I assume you are familiar with creating startup tasks – you need to create a batch file that runs:

Dism /online /Enable-Feature /FeatureName:Windows-Identity-Foundation >> "%TEMP%\WifStartupLog.txt" 2>&1

Here is the error you might be searching for:

Could not load file or assembly ‘Microsoft.IdentityModel Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencie. The system cannot fine the find specified.

SQL Server Configuration Manager RPC Error

On my Dev VM, I’ve been unable to manage SQL Server Express with SQL Server Configuration Manager – I get an error “The Remote Procedure call failed”.

rpc error

The solution: Updates. I found this article:

Which mentions about things breaking wile installing Sql Server 2012 – I didn’t install that, but I did install Visual Studio 2012 – which includes Server Server 2012 components.

Install sql server 2008 sp3, and sql server 2008 r2 sp2. Problems solved.


Windows Live Writer

Windows Live Writer is an oft-overlooked component of the Windows Live Essentials application bundle (also including such gems as Live Photo Gallery, Live Movie Maker, and Live Mesh). If you have a blog (in my case running on WordPress), I highly recommend it for one really important reason: it makes adding images to posts 100% easier.

Think of it like a trimmed down version of Microsoft Word (more like Wordpad really) that can be used to compose blog posts. You can format text according to styles, add hyperlinks effortlessly, perform spell checking – but most importantly – paste images right into your post. Like this one:



You can the resize, crop, etc.

The contents of the Insert tab alone are worth your time:



I could be the only person left who primarily posted using the HTML editor, but if there are any other curmudgeons out there who have been skipping the visual aids because of all the extra steps… well give Windows Live Writer a try!

DIRECTV2PC activation key usage limit error

I have been trying to install DIRECTV2PC for a week or so (off and on of course) and I get the error “Activation Failed” with a reason of “activation key usage limit reached”

For some reason, nobody had a solution – on or (or directv forums, or the internet as a whole).
I had already requested two keys, and I had only used them once – it seems ridiculous to me that I cannot use the key again if I, say, reinstall Windows (which I tend to a couple times a year)…

I found a workaround – use a different email address to request a new key. (Many email providers allow you to insert arbitrary periods in your email address…)

DIRECTV2PC is made by cyberlink for Directv. Nobody seems to know why it requires a product key – probably some accounting thing. Rumor has it that it may be going away soon anyway.

Good luck!

SortedSet wrapper for .net 3.5

Here is a VERY basic SortedSet wrapper for .NET 3.5
The SortedSet is one of the few new features of the .NET Framework 4.0 that I hate to go without. I recently had to drop a Class Library from 4.0 to 3.5, and the SortedSet was the only thing missing. So, I just created my own SortedSet that is build on the SortedList where TValue is a byte,

Here is my implementation – if you need any of the really fancy features, you will need to implement them yourself.

    public class SortedSet<T> : SortedList<T,byte>
        public SortedSet() : base()

        public T Min
                if ((base.Count) >= 1)
                    return base.Keys[0];
                    return default(T);

        public T Max
                if ((base.Count) >= 1)
                    return base.Keys[base.Keys.Count - 1];
                    return default(T);

        public bool Contains(T value)
            return base.ContainsKey(value);

        public void Add(T value)
            base.Add(value, 0);

Disabling the URL rewriting on a SonicWall SSL-VPN bookmark

The SonicWall SSL-VPN 2000 is an impressive and feature-packed appliance. For the most part, I have no complaints (well, it would be nice if it worked on the iPhone or iPad, but this is a bigger issue…), but recently we ran into a rather annoying problem.

The SSL-VPN allows you to configure “bookmarks” that are links to your internal resources. Bookmarks can be Remote Desktop, FTP, VNC, and (among others) http and https. For intranet sites that support basic authentication, it will even push credentials.

All urls accessed through the vpn are rewritten something like: https://sslvpn/go/http://intranetsite/index.html. All URLs referenced within are rewritten as well. This works great until it doesn’t.

Say your intranet page has a link to The SSL-VPN will happily proxy all traffic through itself, rewriting the link to https://sslvpn/go/
Now say you had a link to some cloud-based application that doesn’t tolerate being proxied, and you have a problem.

As far as I can tell, SonicWall provides no option to disable rewriting for a specific bookmark. If you have purchased the Web Application Firewall addon, I believe you can setup exceptions, but I’m not even so sure about that. So… I had to try to figure it out myself.

Well after experimenting and digging, I found a workaround involving javascript redirection, obscuring strings, and overriding functions. While I typically would post my solution, I fear that SonicWall might consider it a security hole and simply patch things up without providing a viable solution. So, if you are pulling your hair out over your SSL-VPN rewriting all your external links – there is hope! Shoot me a comment / email and I’ll see if I can’t help you out.

UPDATE 10/18/2011

One of the people who requested my workaround found that in his case there was a much simpler solution: If you simply need to create a bookmark to an external website, you can just configure the bookmark on the SSL-VPN as an “external website”. My workaround is for the case where you need the SSL-VPN to proxy an internal page, but that page has a link (or redirect) to an external page that gets mangled.


Hiding command window when running VirtualBox Headless

I discovered a couple things today. First, VirtualBox 4 appears to be less resource intensive than Vmware Player for the same workload.

Second, while VirtualBox provides the ability to run in a headless manner (aka hidden, or in the background), the command line tool to do so must be left open (on windows at least)

Yeah… kinda defeats the purpose of being headless.

If you close the cmd window, it kills your VM.

The solution: well here, I’ll just attach it:
(Requires .NET Framework 4 Client Profile)

Just drop it in your c:\Program Files\Oracle\VirtualBox folder (or wherever you installed it to) and invoke it the same as you would VBoxHeadless.exe. Instead of staying open, it will print out the response from VBoxHeadless.exe and return, leaving it running in the background.

All this app does is create a process with a hidden window and passes through the parameters.

Update 9/13/2011: If you are having problems with this not working or otherwise erroring out, it might be because of spaces in the VM Name. Try renaming the VM without spaces and see if that fixes it.
(Thanks David!)

Here is the source code if you are curious.

using System;
using System.Text;
using System.IO;
using System.Diagnostics;

namespace VBoxHeadlessSilent
    class Program
        static void Main(string[] args)
            string headlessPath = "";
            string argString = "";

            for (int i = 0; i < args.Length; i++)
                argString += args[i] + " ";

            headlessPath = Path.Combine(Environment.CurrentDirectory, "VBoxHeadless.exe");
            if (!File.Exists(headlessPath)) headlessPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Oracle", "VirtualBox", "VBoxHeadless.exe");
            if (!File.Exists(headlessPath)) headlessPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Oracle", "VirtualBox", "VBoxHeadless.exe");

            if (File.Exists(headlessPath))
                Process p = new Process();
                p.StartInfo.FileName = headlessPath;
                p.StartInfo.Arguments = argString;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.CreateNoWindow = true;
                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.StartInfo.RedirectStandardOutput = true;
                Console.WriteLine("Could not find VBoxHeadless.exe!");