Disable UAC in Windows 8

Article

In Windows 8, Microsoft changed the UAC slider’s lowest setting from “Disable UAC” to “Hide UAC”.

So, even with the lowest setting programs will still not run with Administrator privileges (like in Windows 7).

Windows' "Run" dialog with UAC still active.
Windows’ "Run" dialog with UAC still active.

To disable UAC, execute this PowerShell script as Administrator (e.g. via powershell from an Admin Command Prompt):

Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLUA" -Value "0"

After that restart and UAC is disabled.

Windows' "Run" dialog with UAC disabled.
Windows’ "Run" dialog with UAC disabled.

Notes:

  • Only do this, if you’re aware of the consequences. Disabling UAC may make the system less secure.
  • The Windows 8 Store can’t be used anymore if UAC is disabled. (You can, especially, no longer installed Windows 8.1.)
  • To reenable UAC, use -Value "1" in the command above.

LINQ to SQL – bits and pieces

Article

In a project I’m currently working on we’re using LINQ to SQL. While most of it is straight forward, there are some quirks that are not that obvious (at least to me).

This article is mostly a FAQ but I will explain some of the not-so-obvious features in more detail.

Note: I’m not going to explain how to setup the connection to the database in this article. I’m assuming that this already works.

Read more →

P/Invoke Tutorial: Passing strings (Part 2)

Article

In the previous tutorial we passed a single string to a native C/C++ function by using P/Invoke.

This function was defined like this:

// C++
void print_line(const char* str);
// C#
[DllImport("NativeLib.dll")]
private static extern void print_line(string str);

However, there exists a hidden pitfall here:

What happens when the user passes a non-ASCII character to this function?

Read more →

P/Invoke Tutorial: Pinning (Part 4)

Article

Sometimes a C/C++ function needs to store data you pass to it for later reference. If such data is a managed object (like a string or class) you need to make sure that the garbage collector doesn’t delete it while it’s still in use/still stored in the native code.

That’s what pinning is for. It prevents the garbage collector from deleting and moving the object.

Read more →