FAQforge provides answers for frequently asked questions for the Linux-, MAC and Windows operating systems.

Remove Desktop Clutter On Windows 7 With PowerShell

Friday, January 27, 2012 - posted by CSch

All of us know the habit of using the desktop as temporary working directory for all kinds of tasks, afterwards leaving most of the files there thinking you might still need them the next day. The day you use them again however never comes and so they remain on your desktop, eventually filling it up to the bottom right corner.
But for lazy people, there are lazy solutions to delay the task of cleaning and tidying up your computer! Just create a folder called Desktop on your Desktop and stuff everything you don’t need into it! Here comes a PowerShell script that does this for you (replace the path to the desktop with the one to yours):

cd C:\Users\howtoforge\Desktop
$path = “C:\Users\howtoforge\Desktop”
$index = 0
$run = 1
while ($run -eq 1) {
if (test-path ($path + “\Desktop_” + $index)) {
$index++
}
else {
mkdir ($path + “\Desktop_” + $index)
$run = 0
}
}
gci $path |
? {$_.Name -notlike “Desktop_*” -and $_.Name -notlike “meta.ps1″} |
Foreach-Object { move-item $_ -destination ($path + “\Desktop_” + $index)}

This script creates a numbered “Desktop_x” folder, takes all the stuff from your desktop except system folders such as the recycle bin, shortcuts and the things you exclude in the script and throws them all inside the created folder.
The only thing you might want to adjust are the items the script excludes – these are given in the line

? {$_.Name -notlike “Desktop_*” -and $_.Name -notlike “meta.ps1″} |

Up to now, the script excludes all the items whose names begin with Desktop_, which is because the script is not supposed to crap its own folders, and the “meta.ps1″ file, which is the name I saved the script under on my desktop.
Copy the script into a notepad and save it as .ps1 file – if you get an error message about converting to a different character set, cancel the saving. This happens upon copying the script from the website to notepad – to solve the issue, look through the script in your notepad for double-quotes and replace those that look odd with new ones. You should now be able to save the document without problems.
To add more files to exclude, copy and paste the bold part of the line (including the space character in front of it) right after itself and replace the name (which is meta.ps1) with the file you want to exclude (you may use wildcards (*) to select multiple files).
To run the script, right-click it and select Run with PowerShell.

The aim of this guide is to create a folder whose content is deleted if the contained files have not been accessed longer than a specific time (this process is applied to single files, not the whole folder). I will choose two weeks for demonstration purposes (= 14 days). Such a folder can be used as temporary folder of any kind, be it for downloaded files/installers or to just keep the desktop clutter-free.
This can be achieved with a combination of PowerShell script and Windows task scheduler. The folder that I will use for this will be C:\Users\howtoforge\Desktop\Temp and is located on my desktop for easy access. To keep order to it, create another folder for your custom scripts if you haven’t already got one, mine will be C:\Scripts.
Open a new instance of notepad and save it in your scripts folder as delete_temp.ps1. .ps1 is the file extension for PowerShell scripts. Now enter following into the script:

cd “C:\Users\howtoforge\Desktop\Temp”;
Get-Childitem | Foreach-Object {if ($_.LastAccessTime -le (get-date).adddays(-14)) {remove-item -recurse -force $_}};

Save the script again. What it does: the script changes into the directory that we want to observe, looks at its items and then deletes every one whose last access time is older than 14 days recursively (it only looks at the items directly placed in the folder, not at subdirectories). The time interval is specified in the adddays attribute of the get-date function here (which can also be addmonths, addhours, etc…) and is a negative number to actually subtract the number of days from the present date. You can change it to your likings.
The script being ready, you have to configure PowerShell to enable calling scripts – therefore open an elevated command line (search the menu for cmd, right-click and select Run as administrator). Open PowerShell by entering

powershell

Afterwards, enter

Set-ExecutionPolicy RemoteSigned

to enable calling scripts. Now you can test your script by right-clicking it and selecting Run with PowerShell. If nothing goes wrong (no red text in the flashing window), proceed to schedule the task, otherwise check your script for errors.

To schedule the task, open Control Panel > System and Security > Administrative Tools > Schedule Tasks. On the left pane, select Task Scheduler Library, then right-click the central task-list and select Create New Task.
On the General tab, give the task a name and a description. Furthermore, choose your version of Windows and optionally choose to run it with highest privileges.
The Trigger tab defines what will call the script – hit New and choose one or more of the various possibilities and events. I choose to run the script when the machine goes idle, since the script will blink up in a PowerShell window when called, and I don’t want that to disturb my work (although it’s really only a split second if you don’t delete several GB of files).
On the Actions tab you define what to do – hit New again. Now don’t enter the actual script as program to run – this goes to the Add arguments line (enter the full path here). What you need to do is to call the PowerShell executable with the script as an argument. I use PowerShell 1.0 which is located in C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe – enter this path into the Program/script line and hit OK.
Now configure the next two tabs for your needs and hit OK again to create the task.

The selected folder will then be scanned for files that haven’t been accessed for longer than the given period every time the task triggers.

Disable Plugin-Container in Firefox

Wednesday, January 25, 2012 - posted by CSch

Plugin-container is a Firefox process designed to ‘out-source’ the plugins used by the browser. Firefox’ model is based on the use of plugins to add functionality, however this goes along with a chance of instability due to a malfunctioning plugin – this would cause the whole browser to collapse since the plugins were all included in one central Firefox process. With the implementation of the plugin-container, the plugins are seperated from the browser process, making it more stable. Now if a plugin crashes, Firefox remains unharmed.
It is known however that this feature causes serious performance issues with many users, that’s why it might be a good idea to test what happens if you deactivate plugin-container (the plugins are not disabled that way, they are just stitched to the main process again).
To do so, open Firefox and direct the URL line to about:config. This is the internal configuration of Firefox, be sure to take the warning that will be shown seriously.
In the search bar on top, enter dom.ipc. A few boolean entries will be shown whose name begins with dom.ipc.plugins (on Firefox 9 there are two, while there are five on some older versions).
Set all of them to false to disable plugin-container:

If this results in performance improvement for you, leave the settings as they are, if there is none however, it is recommendable to switch them back to improve Firefox’ stability.

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.

Using the ReadyBoost Feature on Windows Vista/7

Friday, January 20, 2012 - posted by CSch

ReadyBoost is a Windows feature that uses USB sticks or other flash drives such as SD cards to “speed up your computer”. However the concrete use is not to add the device’s memory to your RAM but to use fast accessible devices as cache storage.

Because of this fact, there are certain conditions that have to be met. The first of course is that you use a flash drive with high reading-rates and access times. If these are lower than those of your hard drive, it will give you nothing. The second is, that you do not turn off your computer every time you complete your work – if you do so every evening, the cache on your flash drive will not even get the chance to properly build up to be used before you shut the computer down. The better choice is to hibernate your computer.
Hibernation is disabled by default on many computers and is not available in the shutdown menu. You can circumvent this however by entering the following into an elevated command prompt (search for cmd, right-click it and Run as administrator):

powercfg -H on

Afterwards right-click on your desktop and create a new shortcut pointing to shutdown.exe /h. Using this shortcut will cause your machine to go into hibernated state (your computer does not use any power here – it just saves the state the current programs are in and cleans the RAM cache, they are restored to that state after turning on the machine again. This happens using a large file where the states are stored in).
Upon hibernating, the flash cache will not be deleted and hence unfolds its use over time.

Another important issue is writing on drives and the defragmentation of drives. The more you write on the drive, the more the flash cache has to be changed – this can result in lower efficiency. If you also defragment the drive, you damage your cache even more – at some point it will become ineffective. Do that only before you choose to completely restart or shutdown your computer (turn off auto defragmentation if you have such things enabled by some kind of software!). Of course, trying to defragment the flash cache will make it unusable.

If you have everything prepared, insert your flash device into the machine. On the what-to-do-with-it prompt, choose Speed up my system using Windows ReadyBoost. Remember not to defragment, restart or shutdown the machine to be able to fully use the device.

Now if you have a decent amount of cache on your flash drive and requests are send to open something, the RAM cache is the first location to look at – if there is nothing there but on your ReadyBoosted drive, the computer will calculate whether it is faster to get the files from your cache or from your hard drive – this is the way ReadyBoost actually can make your machine faster and it has nothing to do with increasing RAM or similar issues.

Adjust Aero To Wallpaper Color on Windows 7

Friday, January 20, 2012 - posted by CSch

There is a tool called <em>Aero Adjuster</em> that works as a tray-icon in the taskbar and changes the colors of your Windows 7 Aero theme every time you change your wallpaper. Furthermore you also have the option to change brightness and/or to invert the colors, ignore black, white and grey tones and to only choose a specific region of the wallpaper (e.g. Top right, Bottom left).

It works automatically but can also be applied manually after changing options.
Download Aero Adjuster here: http://samusaranfreak.deviantart.com/art/Aero-Adjuster-261383189

Infinite Windows 7 Desktop with WindowSlider

Thursday, January 19, 2012 - posted by CSch

WindowSlider is a useful application especially with older non wide-screen monitors since it allows horizontal scrolling of the desktop, as if there were multiple virtual desktops stuck together giving you an infinite work space (the wallpaper and taskbar are static, only the windows move).

It runs as a tray-icon in your taskbar and hast customizable keyboard shortcuts to scroll, but also to jump to active or approximate windows. Furthermore it enables you to scroll by pushing your mouse to one of the side-ends of the screen.
All of the above functions are disengageable.
Download WindowSlider here: http://ficusdev.com/WindowSlider/Description

Windows XP Style Taskbar on Windows 7

Thursday, January 19, 2012 - posted by CSch

One of the most obvious changes on the taskbar since Windows XP is the increased size of the icons and with them, the whole bar. In Windows 7, the whole name identifier was left for the sake of thumbnail previews and slightly bigger icons. However there is a simple option making it possible to reverse the taskbar style back to XP days. To accomplish this, right-click the taskbar and select Properties.

On the appearing window, check the Use small icons checkbox (third from above on the Taskbar tab). In addition, go for the combining-dropdown-menu and select one of the other remaining options, either to combine when the taskbar is full or to never combine.

Customize Your Windows 7 Installation Disk with 7Customizer

Wednesday, January 18, 2012 - posted by CSch

7Customizer is a tool that, with the help of the Windows Automated Installation Kit (WAIK), provides a nice graphical user interface for customizing your Windows 7 installation disk.
To start, insert your disk into the disk drive and copy all of its contents to a folder on your hard drive (this should not contain any space characters in its name and entire path – just call it something like InstallCD and place it directly on the C:\ drive). Next, download and install 7Customizer and the WAIK (see download links below). Run 7Customizer and direct it to the necessary paths:

WAIK usually is installed in the C:\Program Files\Windows AIK directory. The three services that are needed here are located (depending on your architecture – for 32 bit systems it’s x86, for 64 bit systems it’s amd64) in C:\Program Files\Windows AIK\Tools\amd64 and C:\Program Files\Windows AIK\Tools\amd64\Servicing. The fourth line needs to be directed to the folder you put your installation disk’s files into. Afterwards select the Windows version and proceed with customizing your disk:

You may insert language packs, Windows Updates, drivers of any kind, remove parts of the original installation, create an Unattended Script that covers everything but the partitioning (the unattended file can also be created manually with the help of WAIK to automate everything including partitioning, it is up to you which is more suited for your plans) or apply any kind of tweak to your registry or your interface such as customizing your wallpaper, taskbar, etc. etc. To get a burnable image out of the process, check the option to create an ISO-file – these can be made bootable and written on a DVD. Finish your doings on the Apply tab and prepare for a bit of waiting.
The .iso file that is produced is an image of the installation disk. Write it to a DVD and make it bootable.

Download WAIK here: http://www.microsoft.com/download/en/details.aspx?id=10333
Download 7Customizer here: http://www.msfn.org/board/topic/139077-7customizer-a-windows-7-customization-and-deployment-tool/

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