Moving Windows’ Offline File Cache away from C:\

Got a small SSD as your C drive? So do I.
Storing your documents on a network drive? Yep.
Want to index that network drive, to include it in libraries, searches, etc? You bet.

You’ll want to move your offline cache.

  1. Create a folder for your offline file cache. Something like D:\Cache
  2. From an elevated command prompt type the following: takeown /r /f C:\Windows\CSC
  3. Open the Sync Center (typing “sync” into the start menu search field should do) and go to Manage Offline Files.
  4. Click Disable Offline Files and restart the machine.
  5. From an elevated command prompt issue the following commands:
    1. rd /s C:\Windows\CSC
    2. mklink /J C:\Windows\CSC "D:\Cache"
      (or whatever your folder name is, but be sure to use the quotes if you have space(s) in the name).
  6. Reopen the Manage Offline Files window and Enable Offline Files.
  7. Restart the machine.

Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

This error seems to pop up every now and again when I configure a new IIS server, even if I do remember to check the ASP option during the initial role selection.

Here’s how to resolve it (run as admin) on a 64-bit system:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

..and on a 32-bit system:

%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i

Enabling read_committed_snapshot on an existing MSSQL database

In short, for the database named “internal”:

SELECT is_read_committed_snapshot_on, snapshot_isolation_state_desc,snapshot_isolation_state FROM sys.databases WHERE name='internal'
ALTER DATABASE [internal] SET allow_snapshot_isolation ON
ALTER DATABASE [internal] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [internal] SET read_committed_snapshot ON
ALTER DATABASE [internal] SET MULTI_USER
SELECT is_read_committed_snapshot_on, snapshot_isolation_state_desc,snapshot_isolation_state FROM sys.databases WHERE name='internal'

Typing the escape character ^] on a non-english keyboard

This works on a Norwegian keyboard, but may apply to others.

So, your terminal says something like:

Connected to foo
Escape character is ^]

So, ] is easily typed using “Alt Gr + 9″ on my keyboard, but “Ctrl + Alt Gr + 9″ does not produce an escape character.

However, “Ctrl + 5″ does, for whatever reason. If you have a non-english keyboard, try using ^5.

Removing VMware Player or workstation when the Hyper-V role is active

Blatantly stolen from Jussi Palo’s post here, and archived here.
All credit to the original author.

Challenge

Time to go all in with Windows 8 and migrate development environments to Hyper-V.

When you’re migrating from VMware to Hyper-V, and you happen to install Hyper-V before uninstalling VMware Workstation or Player, you will get warning that VMware cannot uninstall while the Hyper-V role is installed on the machine.

Solution

Modify the file C:\ProgramData\VMware\VMware Player\Uninstaller\bootstrap.lua, or C:\ProgramData\VMware\VMware Workstation\Uninstaller\bootstrap.lua using a text editor. You may have to run that editor as an administrator and then open the file from within it.

Comment out the line:

CheckForMSHyperV()

…with two dashes, leaving it as:

--CheckForMSHyperV()

Save the file, and attempt to uninstall VMware again.

Make exim4 on Debian respect .forward and /etc/aliases when using a smarthost

When configured to send all mail through a smarthost, exim4 on Debian will not respect your /etc/aliases file, nor will it care about your users’ ~/.forward files. This is due to the numbering, and consequently the sorting, of the files in /etc/exim4/conf.d/router/.

If you look at 200_exim4-config_primary, you’ll see it handles smarthost routing in smarthost and satellite mode, and that it ends with “no_more”. This means any routes following it will only apply to the local_domains list. Thus, 400_exim4-config_system_aliases and 600_exim4-config_userforward will not be processed for outgoing mail. Not what I want.

To get around this without moving the default files around, I concatenated both the mentioned files into a file called 175_cathedral-config_system_aliases and modified it to apply to the qualify domain. You can name it whatever you want, as long as it starts with a number in between 150 and 200.

Make sure you’ve got your config (dpkg-reconfigure exim4-config) set to “Split configuration into small files”, add your custom file, then run update-exim4.conf and restart exim4.

This is the resulting file, if you just want to copy and paste it:

.ifdef DCconfig_smarthost DCconfig_satellite

cathedral_aliases:
  debug_print = "R: cathedral_aliases for $local_part@$domain"
  driver = redirect
  domains = $qualify_domain
  allow_fail
  allow_defer
  data = ${lookup{$local_part}lsearch{/etc/aliases}}
  .ifdef SYSTEM_ALIASES_USER
  user = SYSTEM_ALIASES_USER
  .endif
  .ifdef SYSTEM_ALIASES_GROUP
  group = SYSTEM_ALIASES_GROUP
  .endif
  .ifdef SYSTEM_ALIASES_FILE_TRANSPORT
  file_transport = SYSTEM_ALIASES_FILE_TRANSPORT
  .endif
  .ifdef SYSTEM_ALIASES_PIPE_TRANSPORT
  pipe_transport = SYSTEM_ALIASES_PIPE_TRANSPORT
  .endif
  .ifdef SYSTEM_ALIASES_DIRECTORY_TRANSPORT
  directory_transport = SYSTEM_ALIASES_DIRECTORY_TRANSPORT
  .endif

cathedral_userforward:
  debug_print = "R: cathedral_userforward for $local_part@$domain"
  driver = redirect
  domains = $qualify_domain
  check_local_user
  file = $home/.forward
  require_files = $local_part:$home/.forward
  no_verify
  no_expn
  check_ancestor
  allow_filter
  forbid_smtp_code = true
  directory_transport = address_directory
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
  skip_syntax_errors
  syntax_errors_to = real-$local_part@$domain
  syntax_errors_text = \
    This is an automatically generated message. An error has\n\
    been found in your .forward file. Details of the error are\n\
    reported below. While this error persists, you will receive\n\
    a copy of this message for every message that is addressed\n\
    to you. If your .forward file is a filter file, or if it is\n\
    a non-filter file containing no valid forwarding addresses,\n\
    a copy of each incoming message will be put in your normal\n\
    mailbox. If a non-filter file contains at least one valid\n\
    forwarding address, forwarding to the valid addresses will\n\
    happen, and those will be the only deliveries that occur.

.endif

EDIT:
I thought I’d mention that the “exim -bt” command is great for testing this kind of thing without actually sending emails.
Run exim -bt foo@bar.com and see what happens.

Samba servers show up slowly in Network Neighborhood when VMware is installed

The VMware virtual network adapters can make browsing the Network Neighborhood in Windows a total pain.
Try using “net view” in a command console (cmd.exe). The command should return results almost immediately. If it takes upwards of a minute, and you have VMware installed, even just the player, then you have this issue.

Go to the advanced network adapter settings, and disable the “Client for Microsoft Networks” for your VMnet adapters. For me, this reduced the time required for servers to show up in the Neighborhood from around a minute to <1 second.

vmware client for microsoft networks

Resetting an Aeon Labs Z-Stick S2

From the manual: This must be done through the host software which takes control of the Z-Stick USB adapter while the Z-Stick is in SerialAPI-Mode.

The Danfoss ZWave PC Controller, previously available here, you can use the “Reset Controller” button to do so. Works fine in VMware Player too, so you don’t need to install a bunch of stuff on your main machine.

zwave_reset

Here are a couple of files to help you out :)
Aeon Z-Stick S2 Manual
Windows Driver
Latest Firmware (as of 2014-08-10)
Danfoss ZWave PC Controller v1.0.5

Reverse SSHFS mounts (fs push)

sshfs is a neat way of mounting a file system from one machine to another over an encrypted ssh channel. However, for machine CLIENT to access a file system that resides on machine HOST, CLIENT must generally be able to log in to HOST. In addition, CLIENT must be able to connect to HOST in the first place, though a tunnel from HOST to CLIENT can easily mediate this if a connection can only be initiated in that direction.

However, the login itself may still be an issue. You might not want to type your password for HOST on CLIENT, or set up a keyless login using public/private keys. You might not entirely trust CLIENT, from which you want to access the file system.

dpipe to the rescue.

Using dpipe, available in the “vde2″ package on Debian (and, likely, derivatives), you can initiate the connection the other way and use sshfs in “slave mode”, in which it communicates over standard input and output instead of an SSH connection directly.

Consider this is what you’d normally do:

sshfs YOU@HOST:/mnt/remote/path /mnt/local/path

.. from CLIENT

Instead, you can do:

dpipe /usr/lib/openssh/sftp-server = ssh CLIENT sshfs :/mnt/remote/path /mnt/local/path -o slave

.. from HOST!

Add any options you want as usual, and you’ve got a reverse SSHFS mount.

One cautionary note: While this setup allows you to initiate the connection from HOST, keeping your login details for HOST private, it will likely still allow for clever people to access the entire file structure of HOST as the client initiating the connection, the same as could happen if you initiate the connection from CLIENT. Thus, some trust in CLIENT is still required, though perhaps considerably less trust than you’d need to do the connection as usual.

Have fun!