Posts Tagged ‘registry’

Change default installation path in Windows 7

Monday, March 25, 2013 posted by CSch

By default Windows installs all programs into the C:\Program Files and C:\Program Files (x86) directories. If the hard drive you have the operating system installed on is running out of space though, or you just want to have the OS on a separate SSD, you might want to consider changing these default installation paths.

Be warned before you go on though! Microsoft does not officially support changing installation directories (see here). You are responsible for all consequences.

Furthermore, since we are going to edit the Windows registry for our causes, you should have that backed up first in case something goes wrong. Here’s how: http://www.faqforge.com/windows/backup-your-windows-registry/

Now that you have been warned, let’s get started: Open a Run… prompt and enter regedit. I will be referring to our new installation path as E:\Program Files and E:\Program Files (x86), so replace these paths with the ones you want to have (you can choose other names as well). Now browse the left registry pane for the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion key. Click on that key once to show its contents and locate the ProgramFilesDir and ProgramFilesDir (x86):

Screenshot (10)

Double click those values and change C:\Program Files to E:\Program Files as well as C:\Program Files (x86) to E:\Program Files (x86). Furthermore it might be safe to change all other paths directing to the old directories to point at the new ones as well. That’s it if you are on a 32bit system, close the registry and reboot your computer.

64bit users have one more step to go. Close the registry and open another Run… prompt. This time, enter %systemroot%\sysWOW64\regedit. Another registry windows will open. Repeat the exact same steps here that you have done before. Afterwards, close the registry and reboot your computer.

Change window border size in Windows 8

Friday, January 4, 2013 posted by CSch

With some help of the Windows registry you can now change the width of Windows explorer borders. This can be nice in terms of style but also really handy since it will become far more easier to grab borders to resize a window.

borders

To change border width, point your cursor to the bottom left corner of the screen and right-click it to open a menu where you choose Run from. In the appearing prompt, enter regedit to get to the registry editor.

In the editor, browse to the HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics key in the left pane and left-click once. On the right pane, look for the BorderWidth and PaddedBorderWidth values set to -15 and -60. Change these to your likings: 0 will give you really small borders, while -200 will give you very thick ones. Don’t meddle with too high numbers though, otherwise you will have a hard times changing the values back!

By default Windows 8′s new start screen allows that many tile rows that fit onto your screen on a certain resolution – however, you can change that value by using the Windows registry.

tilenumber

To get to the registry, point your cursor to the bottom left corner of the screen and right-click it once – a feature-rich menu should appear. Select Run here. In the opened Run-prompt, enter regedit and press Enter to get access.

Warning! Meddling with the registry without knowing what exactly you are doing can cause damage to your machine. To be safe, back up your registry as described here.

Within the registry, use the left navigation panel to get to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ImmersiveShell\Grid key. Select it and look on the right pane afterwards – if there is no value called Layout_MaximumRowCount, create one by right-clicking some free space on the right pane and selecting New > DWORD (32-bit) Value. Name it as shown above and give it the value you want to reduce the number of rows to (the value defines the maximum tile row – you can force it down to a number, but cannot force the screen to use one higher than it would use normally).

Afterwards quit the registry and log out or restart your machine. The metro start screen should now reduce the number of tile rows to the number you entered:

tilenumber2

Change selection box color in Windows 8 and 7

Thursday, August 9, 2012 posted by CSch

The selection box that appears when you hold the left mouse-button and drag your mouse away is blue by default on all versions of Windows. However you can change this setting by using two registry values in Windows 7 and Windows 8.

Open the registry by typing regedit into the Windows 7 menu search on Windows 7 or by right-clicking the bottom left corner on Windows 8 and opening a Run… prompt. Enter regedit into it.

- In the registry you will see a tree structure on the left pane – in it, browse for Computer\HKEY_CURRENT_USER\Control Panel\Colors and click it once.
- On the right pane, look for the value of HotTrackingColor. It is given in three values representing the ratios of red, green and blue that range from 0 to 255. Enter values that mix to the color you want to have (you can check the color values in a graphic editor).
- Do the same for he value of Hilight.

These two values also alter the color of hyperlinks and the color of highlighted text. After you set the values, close the registry and reboot your machine. Afterwards the selection box should have the color you chose.

The two different values each stand for a different part of the box – the first determines the color of the inner transparent space, the second determines the color of the non-transparent border. This means you can have different colors for each.

Remove Driver Filters to Resolve Device Manager Errors on Windows 7

Thursday, February 16, 2012 posted by CSch

Sometimes the situation might come up where a device that was working flawlessly before will stop doing so, even if you try everything – replugging it, reinstalling its drivers, rebooting the computer – but nothing will help.

A possible cause for this is a driver filter that was either installed by any third party software or simply was corrupted. These can be part of any hardware driver and can intercept requests between software and driver (UpperFilter) or between hardware and driver (LowerFilter). Furthermore, there are two types of filter for each relation – device filters and class filters, where device filters work only for specific devices and class filters work for every device of a specific type, for example every bluetooth radio or every USB device attached to your computer. Those class drivers are the ones that usually cause the issues (if it is a filter issue) because on the software’s side, it makes more sense to address those to alter specific behaviours.

If you experience such an issue (which is commonly recognized by the Device Manager errors 19, 31, 32, 37, 39 and 41) it is possible to delete class filters in the registry. Before you make any changes there, it is highly recommendable to back it up. To do so, enter the registry by entering regedit into a Run… prompt and on the left pane, right-click the topmost key (Computer). Click Export and save the file to any location. The file you just created is a .reg file and can be imported into the registry again by simply double-clicking it.

To find the correct filters in the registry, navigate to the Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class key. This will have many subkeys all named like this: {36FC9E60-C465-11CF-8056-444553540000}. These represent the different classes of hardware, you can sport their type by the (Default) or Class values. The one above is for all USB devices:

Along with the other values, those keys contain the class filters if any are present. They are named UpperFilters and LowerFilters. If you have backed up your registry, look for the device giving you headaches and remove the class filters by right-clicking and deleting them.
This guide is only a solution to a possible source of errors and does not cover the whole range – if the problem persists, the source most likely lies somewhere else.

Windows Powershell Script to Export and Import Sound Schemes

Monday, February 13, 2012 posted by CSch

Windows 7 offers the possibility to switch between preinstalled sound schemes and also create new ones and delete those again. What it does not provide however is a way to export and import those schemes to use them on other systems. There is a way to do this but it involves copying over all the custom sound files as well as exporting and importing specific registry keys. This might be a bit too complicated for someone who just wants all their Windows systems to play some nice bird chirp at logon.

Luckily, what is possible on Windows is also scriptable in PowerShell. Therefore the following script is able to export custom sound schemes into a zipped package, including all sound files and needed registry items and also import them onto another system. All the audio files used for the custom scheme to export need to be in the C:\Windows\Media directory – on import, they are all unpacked back there and will not be found if the registry points somewhere else.

$x = “nil”

function SelectFileDialog
{
param([string]$Title,[string]$Directory,[string]$Filter=”Zip archives (*.zip) |*.zip”)
[System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”) | Out-Null
$bFile = New-Object System.Windows.Forms.OpenFileDialog
$bFile.ShowHelp = $true
$bFile.Title = $Title
$bFile.InitialDirectory = $Directory
$bFile.Filter = $Filter
$Show = $bFile.ShowDialog()
If ($Show -eq “OK”)
{
Return $bFile.FileName
}
Else
{
Write-Error “Cancelled by user.”
}
}

function NewZip
{
param([string]$zipFilename)
$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne “.zip”)
{
$zipFilename = $zipFilename + “.zip”
}
set-content $zipFilename (“PK” + [char]5 + [char]6 + (“$([char]0)” * 18))
(dir $zipFilename).IsReadOnly = $false
}

function AddZip
{
param([string]$zipFilename)
$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne “.zip”)
{
$zipFilename = $zipFilename + “.zip”
}$l = $zipFilename.length-4
$iszip = $zipFilename.substring($l)
if ( $iszip -ne “.zip”)
{
$zipFilename = $zipFilename + “.zip”
}
$shellApplication = new-object -com shell.Application
$zipPackage = $shellApplication.NameSpace($zipFilename)

foreach($file in $input)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
}

function ExtractZip
{
param([string]$zipFilename, [string] $destination)

if(test-path($zipFilename))
{
$shellApplication = new-object -com shell.Application
$zipPackage = $shellApplication.NameSpace($zipFilename)
$destinationFolder = $shellApplication.NameSpace($destination)
$destinationFolder.CopyHere($zipPackage.Items())
}
}

$objshell = New-Object -ComObject Shell.Application
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”)
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)

$objform = New-Object System.Windows.Forms.Form
$objform.Text = “Export Windows 7 Sound Scheme”
$objform.Size = New-Object System.Drawing.Size(330,160)
$objform.StartPosition = “CenterScreen”

$objform.KeyPreview = $True
$objform.Add_KeyDown({if ($_.KeyCode -eq “Escape”) {$objform.Close()}})

$exportButton = New-Object System.Windows.Forms.Button
$exportButton.Location = New-Object System.Drawing.Size(20,70)
$exportButton.Size = New-Object System.Drawing.Size(75,23)
$exportButton.Text = “Export”
$exportButton.Add_Click({$x=”exp”;$objform.Close()})
$objform.Controls.Add($exportButton)

$importButton = New-Object System.Windows.Forms.Button
$importButton.Location = New-Object System.Drawing.Size(100,70)
$importButton.Size = New-Object System.Drawing.Size(75,23)
$importButton.Text = “Import”
$importButton.Add_Click({$x=”imp”; $objform.Close()})
$objform.Controls.Add($importButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Size(180,70)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = “Cancel”
$cancelButton.Add_Click({$x=”nil”;$objform.Close()})
$objform.Controls.Add($cancelButton)

$objlabel = New-Object System.Windows.Forms.Label
$objlabel.Location = New-Object System.Drawing.Size(10,20)
$objlabel.Size = New-Object System.Drawing.Size(280,40)
$objlabel.Text = “Do you want to export your current theme or import a new theme?”
$objform.Controls.Add($objlabel)

$objform.Add_Shown({$objform.Activate()})
[void] $objform.ShowDialog()

if($x -eq “nil”) {exit}

if($x -eq “exp”)
{
cd C:\Users\howtoforge\Desktop
$ts = (get-itemproperty (get-item HKCU:\AppEvents\Schemes).PSPath).”(default)”
$a = @()
$b = @()
newzip $ts
Get-ChildItem HKCU:\AppEvents\Schemes\Apps\ | Get-ChildItem | Get-ChildItem |
Foreach-Object {if ((get-itemproperty $_.PSPath).”(default)” -notlike “C:\Windows\Media\*\*”){($efg = ((get-itemproperty $_.PSPath).PSChildName));
if ($efg -eq $ts) { $a += ((get-itemproperty $_.PSPath).”(default)”)
}}}
foreach ($i in $a){ if ($i) {$b += get-item $i}}
$b = $b | select -uniq
get-item $b | addzip $ts
reg export HKCU\AppEvents ($ts + “.reg”)
get-item ($ts + “.reg”) | addzip $ts
remove-item ($ts + “.reg”)
}

if($x -eq “imp”)
{
$p = SelectFileDialog
if ($p)
{
$ppp = (gci $p | select -expandproperty name)
$ps = $ppp.substring(0,$ppp.length-4)
extractzip $p C:\Windows\Media
regedit (“C:\Windows\Media\” + $ps + “.reg”)
Start-sleep -milliseconds 10000
remove-item (“C:\Windows\Media\” + $ps + “.reg”)
$p.remove
}
}

In order to be able to run the script, you need to enable running PowerShell scripts on your systems. Therefore, open a PowerShell as administrator and type in:

set-executionpolicy remotesigned

Now you can run selfmade or signed scripts. Copy and paste the script above into a notepad and find the line that was printed bold here – change my username in the path (“howtoforge”) to yours. Then save it as .ps1 file.

Afterwards you can run the script by right-clicking it and running it in PowerShell or setting that as the default program to open ps1 scripts with. A prompt will pop up that will ask you if you want to ex- or import. Exporting will automatically export your current sound scheme to a zip file on your desktop (but only with the audio files lying in the said folder – exporting any schemes with files in a subfolder such as the Windows schemes will result in missing paths).

Copy the zipped package to the target system and run the script from there, choosing Import this time. Browse for the package and open it. The script will then put all the audio files to the C:\Windows\Media folder and import the registry file (a few pop ups will come up upon importing stuff into the registry, just accept them and everything should be fine).

If any issues should occur, make sure the zipped package is saved to a folder you have writing-permissions and everything for – if you changed it to something else than your desktop, this may easily happen.
If you are told that the registry file does not exist, this is because you waited too long to accept the import – after ten seconds, the .reg file is deleted to not clutter the Media folder. Just import again to solve it.

Remove Arrows From Shortcut Icons on Windows 7

Friday, February 10, 2012 posted by CSch

Upon creating shortcuts on Windows, the icons used for them are always tagged with an additional small arrow icon to indicate that the thing you have there is only a pointer to another file, not the file itself.

If, for esthetical or other reasons, you want remove those arrow icons, you can do that by choosing a transparent icon instead of the arrow to be displayed as indicator so that it won’t be visible anymore. To do that you have to apply a simple registry tweak:
Open the Windows registry by entering regedit into a Run… prompt and browse the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons

If the Shell Icons key does not exist, create it by right-clicking the Explorer key. Next, select the created Icons key and right-click the right pane to create a new String value. Name it 29 and assign the value C:\Windows\System32\shell32.dll,50 to it.
Afterwards close the registry and open a command line by searching for cmd. Enter the following commands one after another (Please note: the first one will close your explorer which means that your windows and taskbar will disappear. The last one is the command to restart your computer, which you need to do to apply all changes):

taskkill /IM explorer.exe /F
cd /d %userprofile%\AppData\Local
del IconCache.db /a
shutdown /r

After rebooting, the icons will be replaced. To revert the changes, simply remove the registry value and execute the commands again.

Export and Import Sound Schemes on Windows 7

Friday, February 3, 2012 posted by CSch

Importing and exporting whole sound schemes becomes handy if you want to apply your schemes to different computers or setup your system anew and don’t want to copy the whole Windows theme. Doing so proves trickier as one might think though, since sound schemes are not saved as some kind of file or package as one might think.

First off, to create a custom sound scheme, head to the Control Panel and open the Hardware and Sound Options. In the Sound menu, click on Change system sounds. Leave the applied scheme as it is and instead change its components by selecting one of the listed items and browsing for a new sound file, which has to be in the .wav format. For simplicity’s sake, put all your custom sound files into the C:\Windows\Media folder prior to setting them since they have to be in the exact same folder on the system you import them.

After you have applied new sounds for all the items you want to change, click the Save as… button and give your scheme a name.

Afterwards, to export the scheme open the Windows registry – do so by opening a Run… prompt (Windows + R) and entering regedit. In the left registry panel, browse for the HKEY_CURRENT_USER\AppEvents key. Right-click it and select Export to save its contents somewhere on your hard drive. Put the exported registry file and all the custom sound files you used on a USB key or another device to transfer the files.

After you have got the registry file as well as the soundfiles you used on the other system, put the sound files in the exact same folder as they were on the first system (if you followed this guide, it is C:\Windows\Media). Then double-click the registry file to add the first system’s sound scheme settings to the new one (schemes are only added, non will be removed if there were custom schemes installed before). The sound scheme should now be available in the Control Panel.

Defragment Boot Files on Windows 7

Monday, January 23, 2012 posted by CSch

Apart from the usual file defragmentation on Windows 7, there is another undocumented function that rearranges boot files to grant faster access on them, resulting in shorter boot times. The usual boot options can be viewed by entering defrag -? into a command line window (this can be done in any command line window; to actually start the defragmentation however you need an elevated command prompt – therefore search for cmd in the menu, right-click it and choose Run as Administrator).
The one we need to use, the /b switch, is not listed there. This undoubtedly has its reasons and you should back-up files before you run it. Do not run it if you fear loss of data.

defrag /b C:

I hereby assume that C: is the drive you have your boot-files on. I ran the command on a Windows 7 Enterprise 64-bit machine and it worked flawlessly.
If upon entering the defrag command you get the errorcode 0×89000017, stating that some registry entries are missing, run the following in an elevated command prompt, wait up to 20 minutes and try again afterwards:

Rundll32.exe advapi32.dll,ProcessIdleTasks

This will initiate some services to start that usually only run when the system is idle, one of them being a service of Superfetch that needs to be run before the defrag /b command.

Disable Autoreboot after Updates on Windows 7

Wednesday, January 18, 2012 posted by CSch

After critical Updates, Windows often needs to restart the computer to apply all changes, which however might not be in the interest of the user. To prevent Windows from auto-restarting (may it be to reduce annoyance or to prevent Windows from stopping unattended running applications), you can use a simple but effective registry entry. To apply it, open the Windows registry by entering regedit into a Run… prompt. On the left column navigate to the Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU key (you might have to create some of the keys if they have not been automatically created yet (right-click the key-tree for that)).

On the right panel, right-click to create a new DWORD-Value (32-bit) and call it NoAutoRebootWithLoggedOnUsers. Assign it the value 1 (which is the same in decimal and hexadecimal). key (you might have to create some of the keys if they have not been automatically created yet (right-click the key-tree for that)).

To reverse the effect, browse the same value again and change it to 0