Windows

From TheBeard Science Project Wiki
Revision as of 14:43, 12 February 2020 by Beard (talk | contribs) (Add Cmd.exe)

Jump to: navigation, search

Batch Scripts

Ping Test a List of Hosts

This crap gave me such a headache because you need ENABLEDELAYEDEXPANSION to increment the counter, but you then can't get errorLevel from a command. I hate batch. This script takes a line-delimited list of hostnames or IPs, pings them, gives an UP/DOWN status for each, then reports the total number of down hosts.

Sample file:

server1
w101.mynet.local
127.0.0.1

Batch script:

@echo off

rem -- Location of line-delimited list of hostnames
set "HOSTLIST=C:\Users\username\Desktop\hostlist.txt"

rem -- Prevent evaluating the entire loop before it's executed
setlocal ENABLEDELAYEDEXPANSION

rem -- Loop through the list of hosts
for /f "tokens=*" %%H in (%HOSTLIST%) do (
	echo Pinging %%H ...
	set ERRLVL=0
	ping -n 3 %%H >nul || set ERRLVL=1
	if /i "!ERRLVL!" equ "1" set /a HOSTSDOWN+=1 & echo DOWN
	if /i "!ERRLVL!" equ "0" echo UP
)

rem -- Print a report 
echo.
if "%HOSTSDOWN%" gtr "0" (
	echo Ping results^: There are %HOSTSDOWN% hosts DOWN.
) else (
	echo Ping result^: All hosts are up.
)

endlocal

pause

CMD Tips and Tricks

Fullscreen CMD Window

To fullscreen cmd on Windows 7/8/10:

  1. Open cmd
  2. type "wmic"
  3. Fullscreen the window
  4. type "exit"

Active Directory

A few commands:

netdom query fsmo - list FSMO roles
netdom query dc - list domain controllers
nslookup -type=srv _gc._tcp.domain.local - find global catalog server
dcdiag /q - query and test domain functions
dcdiag /fix - attempt to repair errors
gpresult - query group policy (2003)
gpresult /r - query group policy (2008)
repadmin /showrepl - show replication history
repadmin /syncall /d /e /a - force replication from current DC
repadmin /replicate dc2 dc1 dc=domain,dc=com - replicate from dc1 to dc2 (they are in reverse order on the command line)
repadmin /replsummary - summary of replication. can be used to verify

Disable UAC in Windows 7

The user interface of User Account Control (UAC) settings in Windows 7 has changed to reflect the move to make UAC less annoying, more user control and more user friendlier approach. In Windows 7, the UAC has a slider bar which allows users to configure and select which level of notification (and hence protection against unauthorized and malicious access) they want. With the fine-tuning of UAC, the wording 'disable' or 'turn off' is no longer available. So how can you disable UAC? Or at least, how can you turn off the notification prompt or pop-up so that they appear less regularly?

In fact, the steps to disable UAC is Windows 7 is similar to steps to disable UAC in Windows Vista, only with slight user interface change, and there is plenty of methods to turn off UAC too.

Method 1: Disable or Turn Off UAC (User Account Control) in Control Panel

To user Control Panel to disable UAC in Windows 7, there are several methods to access the User Account Control settings page:

  1. Go to Start Menu -> Control Panel -> User Accounts and Family Safety -> User Account.
  2. Go to Start Menu -> Control Panel -> System and Security -> Action Center.
  3. Click or right click on Flag icon in notification area (system tray), and then Open Action Center.
  4. Type 'MsConfig' in Start Search to start System Configuration, then go to Tools tab, select Change UAC Settings, then click on Launch button.
  5. Click on User Account Control settings link.
  6. Slide the slider bar to the lowest value (towards Never Notify), with description showing Never notify me.

Windows Optimization

Rough list of things to consider disabling/re-configuring for optimization. I did not write these, I only compiled this list:

  • Application Experience
  • Computer Browser (do not change if computer is on a network)
  • Desktop Windows Manager Session Manager (only needed for Aero display themes)
  • Diagnostic Policy Service
  • Distributed Link Tracking Client
  • IP Helper
  • Offline Files
  • Portable Device Enumerator Service
  • Print Spooler (do not change if you use a printer)
  • Secondary Logon
  • Server (do not change if computer is on a network)
  • Tablet PC Input Service
  • Themes (only change if you use Windows classic theme)
  • Windows Error Reporting Service
  • Windows Media Center Service Launcher
  • Windows Search (only change if you don't/rarely use the search feature)
  • Windows Time (this service checks your clock's accuracy with the time online)
  • ActiveX Installer Service
  • Games
  • Indexing Service (This is the old indexing service that is no longer needed in Vista.)
  • Internet Information Service (Used for hosting websites on your computer.)
  • Microsoft .NET Framework 3.0 (Used for the new .NET 3.0 components, but only really needed for programmers.)
  • Microsoft Message Queue (MSMQ) Server (Used by programmers as a way to reliably queue messages.)
  • Print Services (You only need this if you use internet printers)
  • Remote Differential Compression (This is likely required for utilities that use the network to download files. If it is enabled, don’t mess with it.)
  • Removable Storage Management (The only reason you’d need this is if you are restoring from old NTBACKUP files.)
  • RIP Listener (You won’t need this, it’s a routing protocol.)
  • Services for NFS (This can be used to map a drive to a linux NFS server. Unlikely you’d need it since Samba works so well.)
  • SNMP Feature (This is used for management systems in workplace networks. You don’t need it.)
  • Subsystem for UNIX-based Applications (This is used for compatibility with certain applications based on UNIX… you don’t need it.)
  • Tablet PC Optional Components (If you have a Tablet PC, you should enable this. If you don’t, you may still want to because this includes the Snipping Tool.)
  • Telnet Client (You should never use telnet. Ever.)
  • Telnet Server (You should never use telnet. Ever.)
  • TFTP Client (TFTP was used by many of the early internet worms… there’s a reason it’s disabled by default.)
  • Windows DFS Replication Service (This is only really used in work environments. Don’t bother with this if you are a home user.)
  • Windows Fax and Scan (Why anybody still faxes anything is beyond me.)
  • Windows Meeting Space (If you don’t use Windows Meeting Space or the “People Near Me” feature, don’t bother with this.)
  • Windows PowerShell (PowerShell is a more advanced command line geared towards programmers and system administrators.)
  • Windows Process Activation Service (This is likely required to support some .NET applications, so I wouldn’t change whatever it’s currently set to.)
  • Windows Ultimate Extras (If you like the extras, then enable them. (Ultimate Only))


  • power settings


remove desktop cleanup:

  • right-click>properties>desktop>customize desktop

REGISTGRY FILES

The location of these registry hives are as follows:

HKEY_LOCAL_MACHINE \SYSTEM : \system32\config\system HKEY_LOCAL_MACHINE \SAM : \system32\config\sam HKEY_LOCAL_MACHINE \SECURITY : \system32\config\security HKEY_LOCAL_MACHINE \SOFTWARE : \system32\config\software HKEY_USERS \UserProfile : \winnt\profiles\username HKEY_USERS.DEFAULT : \system32\config\default

Some hives are volatile and don’t have associated files. The system creates and manages these hives entirely in memory; the hives are therefore temporary in nature. The system creates volatile hives every time the system boots. Examples are:

HKEY_LOCAL_MACHINE \HARDWARE : Volatile hive HKEY_LOCAL_MACHINE \SYSTEM \Clone : Volatile hive

These files are database files, and only RegEdit, Regedit32 and the Kernel32 can read them. The primary tool in Windows 7 for working directly with the registry is Registry Editor. To access it, simply type Regedit in Start Menu Search Bar and hit Enter !

DISK CACHE

What is the disk cache?

The disk cache is used to store disk information in RAM. Access to RAM is faster than the hard disk, so the information will be available more rapidly. Getting Started

First and foremost, and as with any registry modification, it is advisable to backup the entire contents of the registry, or at least the key(s) you want to edit. Open the Start menu, click Run and type the command: regedit. Find the following key: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management. In the right column find the "LargeSystemCache" value and double click on it If the value does not exist you will need to create it: Click on an empty part of the window and click "New" Select New > 32-bit DWORD value and name it "LargeSystemCache". Double click on the value and select "Edit" Change the value of LargeSystemCache from 0 to 1, making sure the Hexadecimal option is checked Restart your PC to apply the changes.

ENABLE WRITE CACHE

Go to 'computer management', 'disk management', right-click on the disk and clicl 'properties'. Click the 'policies' tab and check 'enable write cache'.

SUPERFETCH AND DEFRAG ON SSD

i keep superfetch and prefetch enabled, but disable the automatic boot file defrag part of the prefetcher.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters] "EnableBootTrace"=dword:00000000 "EnablePrefetcher"=dword:00000003 "EnableSuperfetch"=dword:00000003

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction] "Enable"="N"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout] "EnableAutoLayout"=dword:00000000

p.s. defragging, while not very useful for an ssd, won't ruin ssd wear leveling. a file that is defragged and occupies one contiguous block of lba's will still be split across multiple nand devices.

BOOT USING ALL CPU CORES

to improve bootup speed:

goto start- type msconfig- open BOOT tab- goto Advanced options- Check Number of processors- select the BIGGEST number on the list (EG. 3,4,6) What it does is makes windows boot using all the cores!

DISABLE GUI BOOT

Run 'msconfig', go to Boot tab, check 'no GUI boot', save, restart.

Screensaver on Hotkey

Run screensaver on hotkey without locking screen

create a shortcut to C:\Windows\System32\[SCREENSAVERNAME].scr and put the shortcut somewhere like in your user folder.

right-click on the shortcut > properties > shortcut > shortcut key

Assign the desired hotkey

Make a Hidden File/Folder Visible

The hidden attribute sometimes is grayed out under properties, usually for system files/folders. You can remove it in the command line:

C:\Users\ILikePie>attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
       [drive:][path][filename] [/S [/D] [/L]]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  I   Not content indexed file attribute.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link

For example:

attrib -h "C:\Users\ILikePie\AppData"

To make it hidden again, use a "+" symbol:

attrib +h "C:\Users\ILikePie\AppData"

For system files, you will likely need to remove the "system file" and "read-only" properties as well:

attrib -h -s -r "C:\Windows\Installer"

You can add the properties back after the hidden property is gone:

attrib +s +r "C:\Windows\Installer"


Automatically Login to Windows 7

  1. Click Start, type netplwiz, and then press Enter.
  2. In the User Accounts dialog box, click the account you want to automatically log on to.If it is available, clear the Users Must Enter A User Name And Password To Use This Computer check box.
  3. Click OK.
  4. In the Automatically Log On dialog box, enter the user’s password twice and click OK.

Rename an ODBC Driver

In HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers, change the name of "DRIVER NAME" to whatever you want.

Rename the, "DRIVER NAME" key in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI to the same name you used above.

Editing Protected Registry Keys

If you have an issue editing, deleting, or renaming a registry key due to an error like The Registry Editor cannot rename X. Error while renaming key. then follow these steps:

  1. Right-click on the key and click "Permissions..."
  2. In the Security tab, click the "Advanced" button at the bottom.
  3. It should say at the top "Owner: TrustedInstaller" (although it may be a different owner). Click "Change".
  4. Type your user name and click Ok.
  5. You can click the box "Replace owner on subcontainers and objects" if you want it to apply to everything withing the key you clicked on. Now clock Ok.
  6. Below the "group and user names" box, click the "Add" button. Type your username and click Ok.
  7. Highlight your name in the "group and user names" box and in the "Permissions for USERNAME" box below, click the checkbox for "Full Control" under the "Allow" column. Now click Ok.

You should now be able to edit the key.

If you want to set the ownership back to Trusted Installer, when you go back to "Change" next to the Owner, you have to make sure that you select your local machine as the "Location", and then you have to type "NT SERVICE\TrustedInstaller" as the username.

Saving Disk Space

Hiberfile

The C:\hiberfile.sys can be several gigs in size. You can remove it by disabling hibernate.

Open cmd as administrator:

powercfg.exe -h off

Paging File

The paging file can be quite large depending on how it's configured. You can either disable paging (not recommended) or move the location of the paging file to another drive. This can be done in Advanced System Settings (from This PC > Properties), then Advanced > Performance (Settings...) > Advanced > Virtual Memory (Change...).

Junctions (Low-Level Filesystem Shortcut)

You can move files to another drive and create a "junction" which is a low-level shortcut that should work on almost any files and folders, even system files.

Open cmd as administrator:

mklink /J <link-destination> <path-source>

Example:

move "C:\ProgramData\Package Cache" "D:\"
mklink /J "C:\ProgramData\Package Cache" "D:\Package Cache"

Restore Points

You can delete old system restore points in Advanced System Settings (from This PC > Properties).

Custom Context Menu

Add Cygwin

add reg key:

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash
	(Default)			REG_SZ		bash
	NoWorkingDirectory	REG_SZ		

add reg key:

[HKEY_CLASSES_ROOT\Directory\Background\shell\bash\command
	(Default)			REG_SZ		C:\cygwin64\bin\mintty.exe /bin/bash -l -c '/transpath.sh "%V"'

If you have trouble editing a registry key, see Editing Protected Registry Keys.

Open Cygwin and create file "/transpath.sh" with contents:

drive=`echo -n "$1"|/usr/bin/grep -Po "^.:"|/usr/bin/tr -d ':'|/usr/bin/tr '[:upper:]' '[:lower:]'`
path=`echo -n "$1"|/usr/bin/sed 's/^.://g'|/usr/bin/sed 's/\\\/\//g'`
cd "/cygdrive/$drive$path"
/bin/bash -i

I usually append this to my .bashrc file in my Cygwin home folder:

PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]$(basename "$(pwd)")\[\e[0m\] \$ '

kill -WINCH $$

h=$HOME

alias cdc='cd /cygdrive/c/Users/$USER/Desktop'
alias cdh='cd /cygdrive/c/Users/$USER/Desktop'
alias c='/bin/clear'
alias h='history'

# fsize: show disk usage of all files/folders in the current directory (non-recursive)
fsize(){
	s=$IFS
	IFS=`echo -en "\n\b"`
	for x in *;do
		echo -en "\e[0;36m$x|\e[0m"
		size=`du -ch "$x" 2>/dev/null|tail -1|sed 's/\x09/ /g'`
		if echo "$size"|grep -q "G";then
			color="\e[0;31m"
			mark="*"
		elif echo "$size"|grep -q "T";then
			color="\e[0;31m"
			mark="*"
		else
			color=""
			mark=""
		fi
		echo -e "$color$size $mark\e[0m"	
	done|column -t -s'|' 2>/dev/null
	IFS=$s
	echo -en "\e[0m"
}

You can now right-click in Explorer and a "bash" option is available which will open a terminal in that directory.

Add Cmd.exe

edit reg key:

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd
	(Default)			REG_SZ		cmd
	NoWorkingDirectory	REG_SZ

	(Original value for Default is @shell32.dll,-8506)

0x00639bc8

Now be sure to rename the "Extended" string value and the HideBasedOnVelocityId DWORD value (if it exists). I just rename them with an underscore at the beginning (ie. "_Extended").

edit reg key:

[HKEY_CLASSES_ROOT\Directory\Background\shell\cmd\command
	(Default)			REG_SZ		cmd.exe /s /k pushd "%V"

If you have trouble editing a registry key, see Editing Protected Registry Keys.

You can now right-click in Explorer and a "cmd" option is available which will open a terminal in that directory.

Windows 10

Startup Folder

In Windows 10, the Startup folder is not visible from the Start menu so you have to find it manually.

The user's Startup folder is located at:
C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

You can get to it quickly by running the Run Command dialog (WinKey + R) and typing:
shell:startup

The common Startup folder (for all users) is located at:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

You can get to it quickly by running the Run Command dialog (WinKey + R) and typing:
shell:common startup

Disable Snap Assist

Snap assist is the thing where after you snap a window, it give you a peek of other windows that you can snap. Here's how to disable it.

Go to Settings > System > Multitasking.

Now disable "When I snap a window, show what I can snap next to it".

Disable Resizing of Adjacent Snapped Windows

By default, when you snap two windows side-by-side and resize one of them horizontally, it will resize the other, making it difficult to know if your windows are ever really center. I never needed this in Windows 7, so to disable it:


Go to Settings > System > Multitasking.

Now disable "When I resize a snapped window, simultaneously resize any adjacent snapped window".

Disable Files/Folder Automatically Added to Quick Access

Open File Explorer.

Navigate to File > Change folder and search options.

Under the General tab, look for the Privacy section.

Uncheck "Show recently used files in Quick access".

Uncheck "Show frequently used folders in Quick access".

Click OK.

Prevent Taskbar Icons Being Added Automatically

I work in an environment where workstations are imaged with a configuration that automatically adds icons to the taskbar for the three major web browsers: Google Chrome, Firefox, and Internet Explorer. Even after removing them, they appear again after logging in again. F*ck that! Here's how to disable it:

Go to %userprofile%\AppData\Local\Microsoft\Windows\Shell

Edit the LayoutModification.xml file.

Locate the <taskbar:TaskbarPinList></taskbar:TaskbarPinList> entry and in that entry remove the <taskbar:... /> lines for the items you want to remove.

Disable Recent Places and Recently Open

The easiest way to turn off Recent Items is through Windows 10’s Settings app. Open “Settings” and click on the Personalization icon.

Click on “Start” on the left side. On the right side, turn off “Show recently opened items in Jump Lists on Start or the taskbar”.

You can also disable “Show recently added apps” if you want.

When you turn off recent items and frequent places, it will clear all recent items from jump lists and File Explorer. Items you pinned, however, will stay in place until you manually unpin them.

Bring Back Windows 7 Photo Viewer

The old Windows 7 Photo Viewer still exists in Windows 10, it's just disabled in the registry.

Save this content to a file like EnableWin7PhotoViewer.reg:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\.bmp]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.cr2]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.dib]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.gif]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.ico]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jfif]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpe]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpeg]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpg]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jxr]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.png]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.tif]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.tiff]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Classes\.wdp]
@="PhotoViewer.FileAssoc.Tiff"

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cr2\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ico\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=hex(0):

Now double-click the file to run it (must be Administrator).

Now go to Settings > Apps > Default apps.

Then under "Photo Viewer" choose the default to be "Windows Photo Viewer".

If you want to undo this, and undo the registry changes, save this content to a file like DisableWin7PhotoViewer.reg and run it:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Classes\.bmp]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.cr2]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.dib]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.gif]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.ico]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jfif]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpe]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpeg]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jpg]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.jxr]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.png]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.tif]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.tiff]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Classes\.wdp]
@=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.cr2\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.dib\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.gif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ico\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpe\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jfif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpeg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jxr\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tif\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.tiff\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wdp\OpenWithProgids]
"PhotoViewer.FileAssoc.Tiff"=-