Category Archives: Windows

windows

Renaming a Domain Controller

Posted on .

You can use netdom to rename any computer, including a domain controller:

However this will leave the attribute msDS-AdditionalDnsHostName with the old name. Check this in ADUC attribute editor (or ADSIEDIT.msc):

Remove the old name and restart.

PS. This fixes not being able to re-use the old name on another computer. You get the error The operation failed because SPN value provided for addition/modification is not unique forest-wide, and you will see the old domain name when you run setspn -l <oldname>. Performing the above attribute changes fixes this.

Hide Dropbox File Explorer Icon


I use dropbox but it isn’t my main sync app. Dropbox doesn’t give you the option to remove the icon from File Explorer, and if you manually remove the registry entries that are related to it, they are recreated at each automated update of Dropbox.

Another way of removing the icon is to add an entry to Windows “NoEnum” registry key. This tells Windows to not process matching keys, so Dropbox just gets ignored.

Add the following registry entries:

Download reg file
  dropbox-removal.reg (476 bytes, 3,040 hits)

Using VBScript to Create Dated Backups with 7-Zip

Posted on .

I needed a simple method to backup a small folder using 7-Zip on a regular basis without installing extra software. I wanted to be able to leave it running daily and have it remove old backups.

I chose VBScript to complete this task, re-learning a few things from the last time I used the language.

The script shall backup C:\Customer to S:\Backup\backup_DATE.7z. It will also delete old backups, only keeping the first 5. The directories and number of kept backups are variables, check the code comments.

Download
  backup-folder.vbs (3.4 KiB, 4,020 hits)

Elevated/Admin Notepad++ Context Menu

Posted on .

I use NotePad++ on Windows and sometimes it is a little frustrating when UAC gets in the way of my editing some files. I have to manually load NotePad++ as Administrator, and try again.

This INF file will install an extra context menu called “Edit with NotePad++ (elevated)”.
notepad_elevated_context_menu

Once downloaded, right click the file and choose Install.

Note: The install script assumes NotePad++ is at “C:\Program Files (x86)\Notepad++\notepad++.exe”. You can adjust the location in the install script by editing the very last line.

Download
  NotepadppElevated.inf (1.3 KiB, 5,301 hits)

(tested on Windows 7 x64)

Logoff Disconnected Users From Remote Desktop via batch-file

Posted on .

I would like to log-off some users after they have disconnected. Windows has this feature built-in, you can find it at the user-properties “Sessions” tab.

However I have found this feature to be unreliable. Whether it is set to log-off disconnected users at 1 minute or 5 minutes, during isolated tests it works fine, but when in production it has failed multiple times in the last few months with disconnected sessions lingering for hours before noticed.

I found this command-line code to log-off all disconnected users. It seemed to fit the purpose. It uses “quser” to get the list of logged on users, writes them to a file, finds the ones that are disconnected and uses “rwinsta” to log them off. Pretty neat.

I felt I could improve on it though. I saw it didn’t really need to write to a temporary file, and just use internal variables. I also wanted it to connect to multiple servers and be able to list specific users to be logged off.

This can then be added to an elevated scheduled task that runs every X minutes to check for disconnected users.

This is working for Windows Server 2008 R2 and Windows Server 2012.

Disconnect listed users:
(adjust the list of servers and users)

Disconnect all users:
(adjust the list of servers)