Archive for the ‘Windows 7’ Category
Export and Import Sound Schemes on Windows 7
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.
Windows Powershell Script to Sort Music From Folder to Library
The aim of the following script was to take music from a single folder with unsorted but tagged audio files and sort them into the music library according to artist and album. It often happens that you have audio files in your browser’s download folder or your instant messenger’s received files folder where they usually don’t belong. The script should be able to move them into your music library and put them into correct folders named after the artist and the album they’re on.
$controlssource = 1
$controlsdest = 1$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 = “Move Audio Data”
$objform.Size = New-Object System.Drawing.Size(300,260)
$objform.StartPosition = “CenterScreen”$objform.KeyPreview = $True
$objform.Add_KeyDown({if ($_.KeyCode -eq “Escape”)
{$objform.Close()}})$movebutton = New-Object System.Windows.Forms.Button
$movebutton.Location = New-Object System.Drawing.Size(20,170)
$movebutton.Size = New-Object System.Drawing.Size(75,23)
$movebutton.Text = “Move”
$movebutton.Add_Click({$x=”move”;$objform.Close()})
$objform.Controls.Add($movebutton)$copybutton = New-Object System.Windows.Forms.Button
$copybutton.Location = New-Object System.Drawing.Size(100,170)
$copybutton.Size = New-Object System.Drawing.Size(75,23)
$copybutton.Text = “Copy”
$copybutton.Add_Click({$x=”copy”;$objform.Close()})
$objform.Controls.Add($copybutton)$cancelbutton = New-Object System.Windows.Forms.Button
$cancelbutton.Location = New-Object System.Drawing.Size(180,170)
$cancelbutton.Size = New-Object System.Drawing.Size(75,23)
$cancelbutton.Text = “Cancel”
$cancelbutton.Add_Click({$a=0;$x=”nil”;$objform.Close()})
$objform.Controls.Add($cancelbutton)$objlabel = New-Object System.Windows.Forms.Label
$objlabel.Location = New-Object System.Drawing.Size(10,110)
$objlabel.Size = New-Object System.Drawing.Size(280,40)
$objlabel.Text = “Please specify whether you want to copy or to move your files. Moving the files will remove them from their original directory.”
$objform.Controls.Add($objlabel)if ($controlssource -eq 1){
$objlabel2 = New-Object System.Windows.Forms.Label
$objlabel2.Location = New-Object System.Drawing.Size(10,10)
$objlabel2.Size = New-Object System.Drawing.Size(280,15)
$objlabel2.Text = “Path to file origin:”
$objform.Controls.Add($objlabel2)}if ($controlssource -eq 1){
$objtextbox = New-Object System.Windows.Forms.TextBox
$objtextbox.Location = New-Object System.Drawing.Size(10,25)
$objtextbox.Size = New-Object System.Drawing.Size(230,20)
$objform.Controls.Add($objtextbox)}if ($controlsdest -eq 1){
$objlabel3 = New-Object System.Windows.Forms.Label
$objlabel3.Location = New-Object System.Drawing.Size(10,50)
$objlabel3.Size = New-Object System.Drawing.Size(280,15)
$objlabel3.Text = “Path to music library:”
$objform.Controls.Add($objlabel3)}if ($controlsdest -eq 1){
$objtextbox2 = New-Object System.Windows.Forms.TextBox
$objtextbox2.Location = New-Object System.Drawing.Size(10,65)
$objtextbox2.Size = New-Object System.Drawing.Size(230,20)
$objform.Controls.Add($objtextbox2)}if ($controlssource -eq 1){
$browsebutton1 = New-Object System.Windows.Forms.Button
$browsebutton1.Location = New-Object System.Drawing.Size(250,24)
$browsebutton1.Size = New-Object System.Drawing.Size(26,22)
$browsebutton1.Text = “…”
$browsebutton1.Add_Click({$fold1 = $objshell.BrowseForFolder(0, “Select Folder”, 0, “”);$objtextbox.Text = $fold1.self.path})
$objform.Controls.Add($browsebutton1)}if ($controlsdest -eq 1){
$browsebutton2 = New-Object System.Windows.Forms.Button
$browsebutton2.Location = New-Object System.Drawing.Size(250,64)
$browsebutton2.Size = New-Object System.Drawing.Size(26,22)
$browsebutton2.Text = “…”
$browsebutton2.Add_Click({$fold2 = $objshell.BrowseForFolder(0, “Select Folder”, 0, “”);$objtextbox2.Text = $fold2.self.path})
$objform.Controls.Add($browsebutton2)}$objform.Controls.Add($copybutton)
#$objform.topmost = $True
$objform.Add_Shown({$objform.Activate()})
[void] $objform.ShowDialog()$sFolder = $objtextbox.Text
$mFolder = $objtextbox2.Text
#$sFolder = “C:\Users\Public\Music\Sample Music”
#$mFolder = “C:\Users\howtoforge\Music”
$objfolder = $objshell.namespace($sFolder)if ($X -eq “nil”) {exit}
foreach ($strfilename in $objfolder.items())
{
for ($a ; $a -le 266; $a++)
{
if ($objfolder.getDetailsOf($objfolder.items, $a) -eq “Contributing artists”)
#if ($objfolder.getDetailsOf($objfolder.items, $a) -eq “Albuminterpret”)
{
$artist = $objfolder.getDetailsOf($strfilename, $a)
}
if($objfolder.getDetailsOf($objfolder.items, $a) -eq “Album“)
{
$album = $objfolder.getDetailsOf($strfilename, $a)
}
}
if ($artist -and $album)
{
if (!(test-path($mFolder + “\” + $artist + “\” + $album + $strfilename)))
{
new-item($mFolder + “\” + $artist + “\” + $album) -itemtype directory
if($x -eq “copy”)
{
copy-item $strfilename.Path ($mFolder + “\” + $artist + “\” + $album)
}
if($x -eq “move”)
{
move-item $strfilename.Path ($mFolder + “\” + $artist + “\” + $album)
}
}
}
clear-variable artist
clear-variable album
$a=0
}
The script runs for every audio file in the specified folder that possesses both given details, here they are Contributing artists and Album (you can change it to look for different details but this does not always make sense since the script later creates the folders in the library depending on those data – there are different artist details however which can be chosen from, since not every audio file has all of them (album artist, contributing artists…). To change them, just change the single instance of them in the script. Adjust their names to the display language of your system!).
If the files have both details specified, the script goes to your library and, if not already present, creates a folder with the artist’s title, a folder with the album title inside of that, and copies or moves the file to that location.
If you have fixed folders that you don’t want to browse anew everytime you run the script, comment out the top two lines and the two bold lines, uncomment the two lines underneath the latter. Change the path given there to the path of your folders. You can also just uncomment one of them, just make sure to comment out the right lines when you uncomment one.
To run the script, copy and paste it into a notepad and save it as .ps1 file (select All Files from the type dropdown menu). Then right-click the file and run it with windows powershell. If it is not working, you might have to change your execution policy if you have not already done so. To accomplish that, search for powershell in the Windows menu search bar and right-click to run it as administrator. Enter
set-executionpolicy remotesigned
and run the script again. The script works finde on my Windows 7 Enterprise 64bit machine with PowerShell 1.0 installed, if some one has improvements to make I’d be glad to read.
Setting the Path Environmental Variable on Windows 7
Whenever you need to call executables from the command line, this is not possible unless you either have directed your console to its location with the cd (change directory) command, or have set it in the PATH variable. The Path variable is a string consisting of one or more data paths seperated by a semicolon and is used every time you call a command to enable the use of executables which are not in your current directory but in one of those you specified in the variable.
To add paths to it, right-click Computer on your desktop or your menu, hit Advanced System Settings and go to the Advanced tab. There, click on Environment Variables… and look for Path under System variables….
Edit it and add a path by placing a semicolon right after the last path and entering the complete path to the folder where your executables are placed.
Remove Desktop Clutter On Windows 7 With PowerShell
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.
Automatically Delete Older Folder Contents with Powershell on Windows 7
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.
Defragment Boot Files on Windows 7
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
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
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





