Example Notepad ++ Secure Session Package

Example Notepad ++ Secure Session Package.#MC-KB19

Written by Giuseppe

Last published at: June 30th, 2023

Example Notepad ++





INSTALL SCRIPT PS1

 

#CUSTOM VARIABLES, EDIT THESE FOR APPLICATION MSI

 

$App = "Notepad++" # app name, also directory name where application will be installed

$ScriptType = "Install" # use Install or Uninstall

$InstName = "npp.8.1.3.Installer.x64.exe" # name of msi to be installed

 

#### Do not edit; these are required to generate the next string

$InstFolder = $App

$ExpPath = [Environment]::ExpandEnvironmentVariables("%secureapppath%")

####

 

$InstFullPath = ("/S /D="+$ExpPath+"\"+"$InstFolder")

 

#not all msi use same switch to set target location for app install

#msi will fall back to the default path if the incorrect switch is used (eg c:\program files\app name)

 

##################################################

 

$t = get-date -Format FileDateTime

$PackageRoot = "Files"

$InstLoc = ("$PackageRoot\$InstName")

 

#logging powershell output

[System.IO.Directory]::CreateDirectory("$ExpPath\Logs")

[System.IO.Directory]::CreateDirectory("$ExpPath\Logs\$App")

Start-Transcript -Path ("$ExpPath\Logs\$App\$ScriptType"+"_"+"PS_Transcript_"+$App+"_"+$t+".txt")

 

#dumping var to output for debug purposes

Write-Host 

Write-Host 

Write-Host "######################################################"

Write-Host 

Write-Host "Script start time:" $t

Write-Host "Script type:" $ScriptType

Write-Host "Application to be installed:" $App

Write-Host "Expanded Environment Variable:" $ExpPath

Write-Host "Root directory for installer:" $PackageRoot

Write-Host "Installer file location:" $InstLoc

Write-Host "Target path for application:" $InsFolder

Write-Host "EXE switch for target path:" $InstFullPath

Write-Host 

Write-Host 

Write-Host "######################################################"

Write-Host 

Write-Host 

 

#creating install path and MSI_Store (to copy msi locally for debug purposes)

[System.IO.Directory]::CreateDirectory("$ExpPath\$InsFolder")

[System.IO.Directory]::CreateDirectory("$ExpPath\MSI_Store")

 

#copying MSI to local path for debug purposes

robocopy /xc /xn /xo $PackageRoot "$ExpPath\MSI_Store" $InstName

 

Write-Host 

Write-Host "######################################################"

Write-Host 

Write-Host "Performing" $ScriptType "of" $InstName "please wait"

 

#running EXE for installer

Start-Process -NoNewWindow -Wait -FilePath $InstLoc -ArgumentList "$InstFullPath"

 

Write-Host 

Write-Host "SHORTCUT FOR PROFILE LOCAL APPLICATION:"

Write-Host "$ExpPath\$InsFolder\notepad++.exe"

Write-Host 

Write-Host "######################################################"

Write-Host 

Stop-Transcript

Write-Host 

Write-Host "######################################################"

Write-Host 

 


The %secureapppath% system variable matches the mount point inside the Profile Editor

 


UNINSTALL SCRIPT PS1

 

#CUSTOM VARIABLES, EDIT THESE FOR APPLICATION MSI

 

$App = "Notepad++" # app name, also directory name where application will be installed

$ScriptType = "Uninstall" # use Install or Uninstall

$InstName = "uninstall.exe" # name of msi to be installed

 

#not all msi use same switch to set target location for app install

#msi will fall back to default path if incorrect switch is used (eg c:\program files\app name)

 

##################################################

$t = get-date -Format FileDateTime

$InsFolder = $App

$PackageRoot = "Files"

$ExpPath = [Environment]::ExpandEnvironmentVariables("%secureapppath%")

$InstLoc = ("$ExpPath\$InsFolder\$InstName")

 

#logging powershell output

[System.IO.Directory]::CreateDirectory("$ExpPath\Logs")

[System.IO.Directory]::CreateDirectory("$ExpPath\Logs\$App")

Start-Transcript -Path ("$ExpPath\Logs\$App\$ScriptType"+"_"+"PS_Transcript_"+$App+"_"+$t+".txt")

 

#dumping var to output for debug purposes

Write-Host 

Write-Host Write-Host "######################################################"

Write-Host 

Write-Host "Script start time:" $t

Write-Host "Script type:" $ScriptType

Write-Host "Application to be installed:" $App

Write-Host "Expanded Environment Variable:" $ExpPath

Write-Host "Root directory for installer:" $PackageRoot

Write-Host "Installer file location:" $InstLoc

Write-Host "Target path for application:" $InsFolder

Write-Host 

Write-Host Write-Host "######################################################"

Write-Host 

Write-Host

 

#creating install path and MSI_Store (to copy msi locally for debug purposes)

[System.IO.Directory]::CreateDirectory("$ExpPath\$InsFolder")

[System.IO.Directory]::CreateDirectory("$ExpPath\MSI_Store")

 

#copying MSI to local path for debug purposes

robocopy /xc /xn /xo $PackageRoot "$ExpPath\MSI_Store" $InstName

 

Write-Host 

Write-Host "######################################################"

Write-Host 

Write-Host "Performing" $ScriptType "of" $InstName "please wait"

 

#running uninstaller

Start-Process "$InstLoc" -Wait -ArgumentList "/S"

 

Write-Host 

Write-Host "######################################################"

Write-Host 

Stop-Transcript

Write-Host 

Write-Host "######################################################"

Write-Host 




Application Shortcut



%PROGRAMFILES%\TSTSecureApps\Notepad++\notepad++.exe