Make Windows Photo Viewer the default image viewer on Windows 10

Windows 10 Creator update replaced (read: forced users to use) the Microsoft Photos app with Microsoft’s new Paint 3D. I didn’t like Microsoft Photos app, and I really dislike Paint 3D.

I found an article on Howto Geek and it provides a downloadable Registry tweak to actually bring back the older Windows Photo Viewer that most of us are familiar with from Windows 7.

Note: If you do not want the older Windows Photo Viewer and just prefer the Microsoft Photos app, you can install that app from the Microsoft Store.

I have also saved the download and have made it available from this server as well.

Forgotten Scripts

Came across a script I wrote some time ago. Sitting there in my user directory was patch.cmd. As I find my scripts, I’m putting them in Git for historical purposes… and for a good laugh.

What in the actual fuck are you, patch.cmd? –Rich

One thing I learned;  document the damn things.  I had no idea what this was, but I knew it was mine because of some of the commentary in the batch script.

Anyway, this script was used to patch atmfd.dll (see: MS15-078 Bulletin).

@echo off

if NOT %~n0==patch IF NOT %~n0==unpatch goto FAILINIT

reg Query HKLMHardwareDescriptionSystemCentralProcessor | find /i x86 > NUL && set ARCH=32BIT || set ARCH=64BIT

for /f tokens=2* %%a in ('REG QUERY HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion /v CurrentVersion') do set WINV=%%~b

REM Operating system              Version number
REM ----------------------------  --------------
REM Windows 10 Tech.Preview       10.0
REM Windows Server Techn.Preview  10.0
REM Windows 8.1                    6.3
REM Windows Server 2012 R2         6.3
REM Windows 8                      6.2
REM Windows Server 2012            6.2
REM Windows 7                      6.1
REM Windows Server 2008 R2         6.1
REM Windows Server 2008            6.0
REM Windows Vista                  6.0
REM Windows Server 2003 R2         5.2
REM Windows Server 2003            5.2
REM Windows XP 64-Bit Edition      5.2
REM Windows XP                     5.1
REM Windows 2000                   5.0


REM check to see if goto label is there.  if it's not, then we're not on a supported
REM system or Rich is a dork.
findstr /r /i /c:^:%~n0_%WINV%_%ARCH% %0>nul
if errorlevel 1 (
echo.
echo Looks like this system is not supported.  %ARCH% - Windows - %WINV%
goto EOF
)


goto %~n0_%WINV%_%ARCH%

REM catchall - shouldn't get here.
goto EOF

pause

:patch_6.0_32BIT
goto patch_1_32BIT

:patch_6.0_64BIT
goto patch_1_64BIT

:patch_6.1_32BIT
goto patch_1_32BIT

:patch_6.1_64BIT
goto patch_1_64BIT

:patch_6.2_32BIT
goto patch_2_32BIT

:patch_6.2_64BIT
goto patch_2_64BIT

:patch_6.3_32BIT
goto patch_2_32BIT

:patch_6.3_64BIT
goto patch_2_64BIT

:patch_10.0_32BIT
goto patch_2_32BIT

:patch_10.0_64BIT
goto patch_2_64BIT

REM unpatch routines

:unpatch_6.0_32BIT
goto unpatch_1_32BIT

:unpatch_6.0_64BIT
goto unpatch_1_64BIT

:unpatch_6.1_32BIT
goto unpatch_1_32BIT

:unpatch_6.1_64BIT
goto unpatch_1_64BIT

:unpatch_6.2_32BIT
goto unpatch_2_32BIT

:unpatch_6.2_64BIT
goto unpatch_2_64BIT

:unpatch_6.3_32BIT
goto unpatch_2_32BIT

:unpatch_6.3_64BIT
goto unpatch_2_64BIT

:unpatch_10.0_32BIT
goto unpatch_2_32BIT

:unpatch_10.0_64BIT
goto unpatch_2_64BIT



:patch_1_32BIT
cd %windir%system32
takeown.exe /f atmfd.dll
icacls.exe atmfd.dll /save atmfd.dll.acl
icacls.exe atmfd.dll /grant Administrators:(F)
rename atmfd.dll x-atmfd.dll
echo.
echo Done patching Windows %WINV% (%ARCH%)
echo.
goto EOF

:patch_1_64BIT
cd %windir%system32
takeown.exe /f atmfd.dll
icacls.exe atmfd.dll /save atmfd.dll.acl
icacls.exe atmfd.dll /grant Administrators:(F)
rename atmfd.dll x-atmfd.dll
cd %windir%syswow64
takeown.exe /f atmfd.dll
icacls.exe atmfd.dll /save atmfd.dll.acl
icacls.exe atmfd.dll /grant Administrators:(F)
rename atmfd.dll x-atmfd.dll
echo.
echo Done patching Windows %WINV% (%ARCH%)
echo.
goto EOF

:patch_2_32BIT
REM I'm not using the registry modification - I planned to, but backed out.  I'll
REM stick to just renaming the file for now.
goto patch_1_32BIT

:patch_2_64BIT
REM I'm not using the registry modification - I planned to, but backed out.  I'll
REM stick to just renaming the file for now.
goto patch_1_64BIT

REM unpatch routines

:unpatch_1_32BIT
cd %windir%system32
rename x-atmfd.dll atmfd.dll
icacls.exe atmfd.dll /setowner NT SERVICETrustedInstaller
icacls.exe . /restore atmfd.dll.acl
echo.
echo Done unpatching Windows %WINV% (%ARCH%)
echo.
goto EOF

:unpatch_1_64BIT
cd %windir%system32
rename x-atmfd.dll atmfd.dll
icacls.exe atmfd.dll /setowner NT SERVICETrustedInstaller
icacls.exe . /restore atmfd.dll.acl
cd %windir%syswow64
rename x-atmfd.dll atmfd.dll
icacls.exe atmfd.dll /setowner NT SERVICETrustedInstaller
icacls.exe . /restore atmfd.dll.acl
echo.
echo Done unpatching Windows %WINV% (%ARCH%)
echo.
goto EOF

:unpatch_2_32BIT
REM I'm not using the registry modification - I planned to, but backed out.  I'll
REM stick to just renaming the file for now.
goto unpatch_1_32BIT

:unpatch_2_64BIT
REM I'm not using the registry modification - I planned to, but backed out.  I'll
REM stick to just renaming the file for now.
goto unpatch_1_64BIT

:FAILINIT
echo Script needs to be named patch or unpatch.

:EOF

vCenter Converter unable to see disks on source

I’m working on converting a physical 2008 R2 server to a virtual machine for ESX 4.1.  I installed vCenter Converter Standalone 4.3 on this machine and ran through the wizard.  When I got to the disk configuration, nothing was listed.

2015-01-27_113507

Some research pointed me to this VMware KB article indicating to check the logs which are located in C:ProgramDataVMwareVMware vCenter Converter Standalonelogs.

2015-01-27_113533

Upon reviewing the logs, I see the following error:

[#1] [2015-01-27 11:31:16.775 04316 warning 'App'] Failed to get info for \.PhysicalDrive0: error Read \.PhysicalDrive0 disk layout: Incorrect function (1)

Researching this error, I arrive at another VMware KB article which indicates GPT partition support was not available in vCenter Converter editions lower than 5.1 (I had installed 4.3).

2015-01-27_113540

 

Get Last Windows Update Installation Date

This command will give you the last date and time Windows updates were installed on a computer.

reg query HKLMSoftwareMicrosoftwindowscurrentversionwindowsupdateauto update
esultsinstall /v LastSuccessTime

Use Runas in a Batch Script

Runas does not accept a password on the command line, nor can you pipe it to it on STDIN. It requires keyboard input.

However, to make life easier, there’s a Visual Basic Script available that will allow you to use Runas from the command line and supply a password to it. It is created by Jefferey Hicks (MS MVP Powershell) and is called VBRunas.

cscript //nologo runas.vbs <Username> <Password> <Command>

You can download the script from my server, or from Jeffery’s website.

List Mapped Drives of Remote Computers using Powershell

This Powershell script is pieced together from a handful of source (noted in script) that will return mapped drives of remote computers of ALL the users.

# cooked by Rich Kreider 
# bits and pieces from:  https://gist.github.com/881412
# http://technet.microsoft.com/en-us/library/ff730940.aspx
# http://andrew-henderson.me.uk/computing/powershellmenu/182-powershellgetremoteloggedonusername
# http://serverfault.com/questions/81797/script-to-list-current-users-mapped-network-drives
# http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25075337.html
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394194(v=vs.85).aspx
# http://blogs.msdn.com/b/powershell/archive/2006/11/03/erroraction-and-errorvariable.aspx
# http://blogs.msdn.com/b/dmuscett/archive/2009/05/27/get_2d00_wmicustom.aspx
# http://poshcode.org/882
# http://blogs.technet.com/b/heyscriptingguy/archive/2005/10/27/how-can-i-determine-which-drives-are-mapped-to-network-shares.aspx


#$objUser = New-Object System.Security.Principal.NTAccount("fabrikam", "jdoe")
# get logged on user
#$loggedOn = gwmi win32_computersystem -ComputerName . -namespace "rootcimv2"

# the following gets username and sid
#$objUser = new-object system.security.principal.ntaccount("fabrikam", #$loggedOn.username.split("")[1])
#$strSID = #$objUser.Translate([System.Security.Principal.SecurityIdentifier])
#"SID: "+$strSID.Value
#"Username: "+$loggedOn.UserName.split("")[1]

$saveAs = 'c:ManualMappings.csv'
$ErrorActionPreference="SilentlyContinue"
$USE_ADS=False  # Set this to false if you don't have Quest ActiveRoleManagement snapin.  You can download:  http://www.quest.com/powershell/activeroles-server.aspx


function getData($data) {
        write-host "`tEnumerating SubKeys"
        foreach ($key in $HKU.GetSubKeyNames()) {
            $keys = $HKU.OpenSubKey($key + 'Network')

            # Move on to the next $key if the 'Network' sub key is empty or non-existent
            if ($keys.SubKeyCount -le 0) { continue }

            # Iterate through each drive letter (a corresponding key name) and output drive mapping
            foreach ($driveletter in $keys.GetSubKeyNames()) {
                $values = $keys.OpenSubKey($driveletter)

                # Attempt to translate the SID into a friendly username
                try {
                    $sid = New-Object System.Security.Principal.SecurityIdentifier($key)
                    $user = $sid.Translate([System.Security.Principal.NTAccount])
                }
                # Fallback to displaying SID
                catch {
                    $user = $key
                }
                # Output result to file specified in $saveAs
                $matches.name+",$user,$driveletter," + $values.GetValue('RemotePath') | Add-Content $saveAs
            }
        }
        write-host "`tDone"
}




if ($USE_ADS -eq $TRUE) {
add-pssnapin quest.activeroles.admanagement
$computers = get-qadcomputer | foreach-object {$_.name}
} else {
$computers=switch -regex (net view) { "^(?S+)s+" { $matches.name }}
}

foreach ($computer in $computers) {

    write-host "Trying " $computer
    $HKU = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Users', $computer)
    if ($? -eq $FALSE) # $? is a Boolean value that holds the status of the last operation: success or failure.
    {
        write-host "`tRemoteRegistry Connect Fail"
	    # maybe remote registry wasn't enabled, try enabling and run again
    	write-host "`tAttempting to start RemoteRegistry"
        (gwmi win32_service -filter "Name='RemoteRegistry'" -computer $computer -ea silentlycontinue).invokemethod("StartService",$null) | out-null
        if ($? -eq $FALSE)
        {
            write-host "`tNot able to start RemoteRegistry"
        } else {
            write-host "`tRemoteRegistry Started"
			$HKU = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Users', $computer)
            if ($? -eq $FALSE)
            {
                write-host "`tFailed to Connect and Start RemoteRegistry"
            } else {
                write-host "`tRemoteRegistry Connected"
		    	$computer+",N/A,N/A,N/A" | add-content $saveAs
			}
		}
    } else {
        write-host "`tRemoteRegistry Connected"
        getData($HKU.GetSubKeyNames())
    }
    } #end-foreach 

There’s probably a handful of issues with this but I at least wanted to get the script up so I could reference it. I’ll clean it up when I get some free time and make it work faster/better but I just don’t have the time right now.

My notes for HMailserver and SpamAssassin on Windows

These are quick notes on configuring spamassassin filtering with the free HMailserver mail server on Windows.  Takes less than 10 minutes to do this and it is pretty effective in my initial testing.  Note that I have not tweaked Spamassassin much.

  • Install HMailServer (outside scope of this note):  http://hmailserver.com/
  • Download SpamAssassin pre-built by JAM Software and Install:  http://www.jam-software.com/spamassassin/
  • Grab NSSM (non-sucking service manager):  http://nssm.cc/download/?page=download
  • Install the spamassassin service with this command:   nssm install spamassassin c:program filesjam softwarespamassassin for windowsspamd.exe
  • Modify service via services.msc and set the Recovery options to REstart the service for each item
  • Create Windows task to update spamassassin rules (sa-update) nightly.  The new task should run daily, somewhere around 1am I suppose.  Point the executable to:  c:program filesjam softwarespamassassin for windowssa-update.bat
  • Modify sa-update.bat and add the following two lines after the sa-update command:
    sc stop spamassassin
    sc start spamassassin
  • Open c:program filesjam softwarespamassassin for windowsupdatechannels.txt and add the following (or your own) channels:
    sought.rules.yerp.org
  • Start the spamassassin Windows service or restart it.  Make sure spamd process is running.  Confirm in Task Manager or however you want.  If prompted, allow it through Windows firewall or add the TCP port 783 yourself to Windows firewall.
  • In HMailServer Admin panel, Navigate Settings -> Anti-Spam -> SpamAssassin tab.
  • Enable:  Use Spamassassin
  • Check Use score from SpamAssassin
  • Click Test… and verify results.
  • Modify c:program filesjam softwarespamassassin for windowsetcspamassassinlocal.cf to your needs.
  • Restart spamassassin service

How to Search PDF Files on Windows 7

I downloaded a whole resource ZIP of VMware vSphere PDF books from VMware’s website and was looking for something particular in the PDF files.  There were 10s of PDF files and I didn’t feel like opening each one individually and searching so I decided to find a way to search them natively with Windows built-in indexing/search.

Turns out Adobe actually makes a search filter but on Windows 7 64bit it is not installed so you have to download the filter from Adobe’s website:  Download Here

1. Download and extract the contents of “PDFiFilter64installer.zip” to your local drive.
2. Double click “PDFFilter64installer.msi” to launch the installer.
3. Follow the instructions in the installer wizard to complete the installation.

[tip]After installing the PDF iFilter, it is recommended that you set your system PATH environment variable to the “bin” folder of the “Ifilter” installation. For example, from the “Control PanelSystemAdvancedEnvironment Variables” tab, append to PATH “C:Program FilesAdobeAdobe PDF iFilter 9 for 64-bit platformsbin” and then restart the computer.[/tip]

You can confirm it is installed by checking in Control Panel (Start -> “control” [ENTER]) then in the search box at the top right type “indexing options” and choose “Indexing Options” link then Advanced and then File Types and look for PDF.

iFilter Installed

Adobe IFilter Installed

 

Filter NOT Installed

Adobe IFilter NOT Installed