Friday, June 9, 2017

Silently Deploy Read & Write 12 via SCCM

Read & Write 12 is an accessibility software we have licensed here at the University. I recently had to create a deployment for version 12 (we have version 11 deployed right now), and I thought I would post the script here in case it helps anyone, including my future self.
The install is fairly straight forward. I discovered some things and tweaked the script until the install was working the way I want. You may not need the entire script if you did not have v11 installed or need the folder cleanup. The script performs the following functions:
  • Uninstall the existing v11.
  • Cleans up a directory (RW Admin) we created during our v11 install.
  • Installs v12.
  • Adds registry entry that licenses product. If you do not have a site license you can omit this, and the user would have to authenticate each time they run the program.
  • Copy RWSettings.xml file to all user profiles during install. Settings in this file will turn off the auto update v12 performs when first run for each user, as well as turn off the check for updates. Keeping the update from running also stops the program from recreating a new shortcut on the Public profile, which I cleaned up during install.
  • Remove the shortcut from the Public Desktop. (Our labs have clean desktops rather than icons for each of the installed application, which can number over 75)
  • Open firewall ports for readandwrite.exe. I am not sure why it tries to open these ports, but I don't want it prompting the user (who is a non-admin and cant open ports anyway) You could also close these ports by using parameter -Action Block instead of Allow if you knew you didn't want that functionality. Opening the firewall ports use the POSH command "New-NetFirewallRule" which only exists in Win8.1 and 10. We are moving completely off Windows 7 this summer, so I don't have to worry about it working on Win7.  If you do, you can use a netsh command instead. Or update to Windows 10.
To get the RWSettings.xml file, I installed Read & Write 12 on a box, and grabbed it from the user's profile\Appdata\Roaming\Texthelp\ReadAndWrite\12\RWSettings.xml. Then I opened it up with my favorite text editor and changed the two lines to true and false respectively:


The powershell install script looks like this, or you can grab it from Github.

David Pearson,

Installs Read & Write 12

Firewall port command New-NetFireWallRule requires Win8.1 or better.
Need to get RWSettings.xml from users profile after install, and set
StartUpWizardHasRun to true and AutoCheckForUpdates to false
Then copy file to C:\Users\profile\AppData\Roaming\Texthelp\ReadAndWrite\12 during install
Program is licensed by adding key to registry.

$currentDirectory = split-path -parent $MyInvocation.MyCommand.Definition

# Uninstall Existing Software
$SoftwareInstalls = get-wmiobject -namespace root\cimv2\sms -query "select * from SMS_InstalledSoftware where ProductName = 'Read And Write 11'"
foreach ($SoftwareInstall in $SoftwareInstalls)
  $software = $Softwareinstall.softwarecode
  $arguments = "/x $software /qn /norestart"
  start-process msiexec.exe -ArgumentList $arguments -wait

if (Test-Path "$ENV:SystemDrive\RW Admin")
 remove-item -Path "$ENV:SystemDrive\RW Admin" -Force -Recurse

# Start Install
Start-Process "$currentDirectory\Read&Write.exe" -ArgumentList "/v/qn" -Wait

reg add "HKLM\SOFTWARE\WOW6432Node\Texthelp\Read&Write" /v "ProductCode" /t REG_SZ /d "MY_LICENSE_CODE" /f

# Copy file to Default Profile that removes first run autoupdate and disables autoupdate for all New Users
if (! (Test-Path "$ENV:SystemDrive\Users\Default\AppData\Roaming\Texthelp\ReadAndWrite\12"))
 mkdir "$ENV:SystemDrive\Users\Default\AppData\Roaming\Texthelp\ReadAndWrite\12"

Copy-Item -Path "$currentDirectory\RWSettings.xml" -Destination "$ENV:SystemDrive\Users\Default\AppData\Roaming\Texthelp\ReadAndWrite\12\" -Force

# Copy file to all the user profiles that removes first run autoupdate and disables autoupdate for existing users.
$Users = Get-ChildItem -Path $ENV:SystemDrive\Users\ -Exclude "Public","Default.migrated"
foreach ($User in $Users) {
  $profile = $User.Name
 if (! (Test-Path "$ENV:SystemDrive\Users\$profile\AppData\Roaming\Texthelp\ReadAndWrite\12"))
   mkdir "$ENV:SystemDrive\Users\$profile\AppData\Roaming\Texthelp\ReadAndWrite\12"
 Copy-Item -Path "$currentDirectory\RWSettings.xml" -Destination "$ENV:SystemDrive\Users\$profile\AppData\Roaming\Texthelp\ReadAndWrite\12\" -Force


# Remove Shortcut from Public Desktop
if (Test-Path "$ENV:PUBLIC\Desktop\Read&Write.lnk")
 Remove-Item -Path "$ENV:PUBLIC\Desktop\Read&Write.lnk" -Force

# Open Firewall Ports for .exe
New-NetFirewallRule -DisplayName "Read&Write 12" -Direction Inbound -Program "${ENV:ProgramFiles(x86)}\texthelp\read and write 12\readandwrite.exe" -Protocol tcp -Action Allow
New-NetFirewallRule -DisplayName "Read&Write 12" -Direction Inbound -Program "${ENV:ProgramFiles(x86)}\texthelp\read and write 12\readandwrite.exe" -Protocol udp -Action Allow

Gather up all your files, stick them in your Source directory and build your application.

My install string looks like:

powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\Install_ReadWrite12.ps1

The detection method is based on the msi that gets extracted from the .exe. For it I just grabbed the msi product code and version from the test box I had installed it on first instead of digging around for the source msi in C:\Windows\Installer. (I assume that's where it extracts to, I didn't need to go find it)