Pages

Friday, 27 August 2021

Batch script to set a registry key in HKCU registry

 @ECHO OFF

SETLOCAL enabledelayedexpansion


FOR /f "tokens=7 delims=\" %%a in ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" /f "S-1-5-21"') do (

    REG QUERY "HKU\%%a\Software" >nul 2^>^&1

    IF !ERRORLEVEL! EQU 0 (

        ECHO Adding Reg Key to Pre-Enable Open Text 1 for %%a

        REG ADD "HKU\%%a\Software\Microsoft\Internet Explorer\Approved Extensions" /v "{67FFC103-051E-48ED-8F5A-76C9C82A36F2}" /t REG_BINARY /d "51667a6c4c1d3b1b13deea7e2e568b069b503589ca6c75ed" /f

REG DEL "HKU\%%a\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{67FFC103-051E-48ED-8F5A-76C9C82A36F2}" /f 

    )

)


Thursday, 26 August 2021

Add content to azure table PowerShell

# Step 1, use Start-Transcript to capture the execution to a text file and set variables for connecting to Azure Table
#Start-Transcript -Path "C:\TempLogs\NvidiaAdapter-$(((get-date).ToUniversalTime()).ToString("yyyyMMddThhmmssZ")).log"

Start-Transcript -Path "C:\TempLogs\NvidiaAdapter.log"

#storage account details
$storageAccountName = 'laps1'
$tableName = 'PowershellReports'
$sasToken = '?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2022-10-19T15:25:02Z&st=2021-08-24T07:25:02Z&spr=https&sig=jqaTwTTsVOZu08Xu93GVAOtf4mmpKN5IiuMYgOcq%2F78%3D'
$dateTime = get-date
$partitionKey = 'displaydrivers'

# Step 2, Connect to Azure Table Storage
Install-Module -Name Az -Repository PSGallery -Force
Import-Module -Name Az
$storageCtx = New-AzStorageContext -StorageAccountName $storageAccountName -SasToken $sasToken
$table = (Get-AzStorageTable -Name $tableName -Context $storageCtx).CloudTable

# Step 3, Check for presence of hotfix
$graphics = gwmi Win32_VideoController | Where-Object {$_.Name.contains("NVIDIA") } |Select-Object Name
$nvidiadriver = $graphics.Name
$PatchCheck = "$nvidiadriver"
$model = (gwmi Win32_computersystem -computername $env:COMPUTERNAME).model
# Step 4, Write data to Table Storage and end transcript.
Write-Host "Writing to Azure Table $table"
Install-Module AzTable -Force
Add-AzTableRow -table $table -partitionKey $partitionKey -rowKey ([guid]::NewGuid().tostring()) -property @{

'LocalHostname' = $env:computername
'NvidiaAdaptername' = $PatchCheck
'Model' = $model

} | Out-Null
Stop-Transcript

Sunday, 1 August 2021

PowerShell App Deployment Toolkit useful Commands

 ## Commonly used PSADT env variables
 $envCommonDesktop           # C:\Users\Public\Desktop
 $envCommonPrograms          # C:\ProgramData\Microsoft\Windows\Start Menu\Programs
 $envProgramFiles            # C:\Program Files
 $envProgramFilesX86         # C:\Program Files (x86)
 $envProgramData             # c:\ProgramData
 $envUserDesktop             # c:\Users\{user currently logged in}\Desktop
 $envUserStartMenuPrograms   # c:\Users\{user currently logged in}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
 $envSystemDrive             # c:
 $envWinDir                  # c:\windows
 
 ## How to load ("dotsource") PSADT functions/variables for manual testing (your powershell window must be run as administrator first)
 
 cd "$path_to_PSADT_folder_youre_working_from"
 
 . .\AppDeployToolkit\AppDeployToolkitMain.ps1
 
 ## *** Examples of exe install***
 
 Execute-Process -Path '<application>.exe' -Parameters '/quiet' -WaitForMsiExec:$true
 
 Execute-Process -Path "$dirFiles\DirectX\DXSetup.exe" -Parameters '/silent' -WindowStyle 'Hidden'
 
 #open notepad, don't wait for it to close before proceeding (i.e. continue with script)
 
 Execute-Process -Path "$envSystemRoot\notepad.exe" -NoWait
 
 #Execute an .exe, and hide confidential parameters from log file
 
 $serialisation_params = '-batchmode -quit -serial <aa-bb-cc-dd-ee-ffff11111> -username "<serialisation username>" -password "SuperSecret123"'
 
 Execute-Process -Path "$envProgramFiles\Application\Serialise.exe" -Parameters "$serialisation_params" -SecureParameters:$True
 
 ##***Example to install an msi***
 
 Execute-MSI -Action 'Install' -Path "$dirFiles\<application>.msi" -Parameters 'REBOOT=ReallySuppress /QN'
 
 Execute-MSI -Action 'Install' -Path 'Discovery 2015.1.msi'
 
 #MSI install + transform file
 
 Execute-MSI -Action 'Install' -Path 'Adobe_Reader_11.0.0_EN.msi' -Transform 'Adobe_Reader_11.0.0_EN_01.mst'
 
 ## Install a patch
 
 Execute-MSI -Action 'Patch' -Path 'Adobe_Reader_11.0.3_EN.msp'
 
 ## To uninstall an MSI
 
 Execute-MSI -Action Uninstall -Path '{5708517C-59A3-45C6-9727-6C06C8595AFD}'
 
 ## Uninstall a number of msi codes
 
 "{2E873893-A883-4C06-8308-7B491D58F3D6}", <# Example #>`
  "{2E873893-A883-4C06-8308-7B491D58F3D6}", <# Example #>`
  "{2E873893-A883-4C06-8308-7B491D58F3D6}", <# Example #>`
  "{2E873893-A883-4C06-8308-7B491D58F3D6}", <# Example #>`
  "{2E873893-A883-4C06-8308-7B491D58F3D6}", <# Example #>`
  "{B234DC00-1003-47E7-8111-230AA9E6BF10}" <# Last example cannot have a comma after the double quotes #>`
  | % { Execute-MSI -Action 'Uninstall' -Path "$_" } <# foreach item, uninstall #>
 
 ## ***Run a vbscript***
 
 Execute-Process -Path "cscript.exe" -Parameters "$dirFiles\whatever.vbs"

 ## Copy a file to the correct relative location for all user accounts
 
 #grabbed from here: http://psappdeploytoolkit.com/forums/topic/copy-file-to-all-users-currently-logged-in-and-for-all-future-users/
 
 $ProfilePaths = Get-UserProfiles | Select-Object -ExpandProperty 'ProfilePath'
 
 ForEach ($Profile in $ProfilePaths) {
 
     Copy-File -Path "$dirFiles\Example\example.ini" -Destination "$Profile\Example\To\Path\"
 
 }
 
 ##***Remove registry key***
 
 #I dont know the right term, but these are to delete the whole 'folder' reg key
 
 Remove-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayer\SafeVersions' -Recurse
  Remove-RegistryKey -Key 'HKLM:SOFTWARE\Macromedia\FlashPlayer\SafeVersions' -Recurse
 
 #This is to remove a specific reg key item from within a 'folder'
 
 Remove-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Name 'RunAppInstall'
 
 Remove-RegistryKey -Key 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Name 'RunAppInstall'
 
 ## ***Create a reg key***
 
 Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\LMKR\Licensing' -Name 'LMKR_LICENSE_FILE' -Value '@license'-Type String -ContinueOnError:$True
 
 ## ***To set an HKCU key for all users including default profile***
  [scriptblock]$HKCURegistrySettings = {
      # I included both to illustrate that HKCU\ is an acceptable abbreviation
      Set-RegistryKey -Key 'HKEY_CURRENT_USER\SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9' -Name 'NoOpenWith' -Value '""'-Type String -ContinueOnError:$True -SID $UserProfile.SID
      Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'qmenable' -Value 0 -Type DWord -SID $UserProfile.SID
  }Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings
 
  #import a .reg key, useful if there's a butt-tonne of nested keys/etc
 
 Execute-Process -FilePath "reg.exe" -Parameters "IMPORT `"$dirFiles\name-of-reg-export.reg`"" -PassThru
 
 ## To pause script for <x> time
 
 Start-Sleep -Seconds 120
  ## ***To copy and overwrite a file***
 
 Copy-File -Path "$dirSupportFiles\mms.cfg" -Destination "C:\Windows\SysWOW64\Macromed\Flash\mms.cfg"
 
 ## ***To copy a file***
 Copy-File -Path "$dirSupportFiles\mms.cfg" -Destination "C:\Windows\SysWOW64\Macromed\Flash\"
 
 ## ***To copy a folder***
 
 # pls note the destination should be the PARENT folder, not the folder name you want it to be.
 
 # for example, you'd copy "mozilla firefox" to "c:\program files", if you were wanting to copy the application files.
 
 # if copying to root of c:, include trailing slash - i.e. "$envSystemDrive\" not "$envSystemDrive" or "c:"
 
 Copy-File -Path "$dirFiles\client_1" -Destination "C:\oracle\product\11.2.0\" -Recurse
 
 ## ***To delete a file or shortcut***
 
 Remove-File -Path "$envCommonDesktop\GeoGraphix Seismic Modeling.lnk"

 ## Remove a bunch of specific files
 "$envCommonDesktop\Example 1.lnk", <# Example #>`
 "$envCommonDesktop\Example 2.lnk", <# Example #>`
  "$envCommonDesktop\Example 3.lnk" <# Careful with the last item to not include a comma after the double quote #>`
  | % { Remove-File -Path "$_" }
 
 ## Remove a bunch of specific folders and their contents
 
 "$envSystemDrive\Example Dir1",  <# Example #>`
 "$envProgramFiles\Example Dir2",  <# Example #>`
 "$envProgramFiles\Example Dir3",  <# Example #>`
 "$envProgramFilesX86\Example Dir4",  <# Example #>`
 "$envSystemRoot\Example4" <# Careful with the last item to not include a comma after the double quote #>``
 | % { Remove-Folder -Path "$_" }
 
 ## Remove a bunch of specific folders, only if they're empty
 <# Use this by specifying folders from "deepest folder level" to "most shallow folder level" order e.g.
  c:\program files\vendor\app\v12\junk - then  
 c:\program files\vendor\app\v12 - then
 c:\program files\vendor\app - then
 c:\program files\vendor
 using the above example, it will only remove c:\program files\vendor if every other folder above is completely empty.
 
 if for example v11 was also installed, it would stop prior #>
 
 (
 
     "$envProgramFiles\vendor\app\v12\junk",
     "$envProgramFiles\vendor\app\v12",
     "$envProgramFiles\vendor\app",
     "$envProgramFiles\vendor",
     "$envProgramFilesX86\vendor\app\v12\junk",
     "$envProgramFilesX86\vendor\app\v12",
     "$envProgramFilesX86\vendor\app",
     "$envProgramFilesX86\vendor" <# careful not to include the comma after the double quotes in this one #>
      ) | % { if (!(Test-Path -Path "$_\*")) { Remove-Folder -Path "$_" } }
 
# for each piped item, if the folder specified DOES NOT have contents ($folder\*), remove the folder
  ## Import a certificate to system 'Trusted Publishers' store.. helpful for clickOnce installers & importing drivers
  # (for references sake, I saved as base64, unsure if DER encoded certs work)
 
 Execute-Process -Path "certutil.exe" -Parameters "-f -addstore -enterprise TrustedPublisher `"$dirFiles\certname.cer`""
  Write-Log -Message "Imported Cert" -Source $deployAppScriptFriendlyName
 
 ## Import a driver (note, >= win7 must be signed, and cert must be in trusted publishers store)
 
 Execute-Process -Path 'PnPutil.exe' -Parameters "/a `"$dirFiles\USB Drivers\driver.inf`""
 
 ## Register a DLL module
 
 Execute-Process -FilePath "regsvr32.exe" -Parameters "/s `"$dirFiles\example\codec.dll`""
 
 ## Make an install marker reg key for custom detections
  #for e.g. below would create something like:
  #HKLM:\SOFTWARE\PSAppDeployToolkit\InstallMarkers\Microsoft_KB2921916_1.0_x64_EN_01
 
 Set-RegistryKey -Key "$configToolkitRegPath\$appDeployToolkitName\InstallMarkers\$installName"
 
 ## While loop pause (incase app installer exits immediately)
 
 #pause until example reg key
 
 While(!(test-path -path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{product-code-hereD}")) {
 
                 sleep 5;
 
                 Write-Log -Message "$appVendor - $appName - $appVersion is still not finished installing, sleeping another 5" -Source $deployAppScriptFriendlyName;
 
 }
 
 #pause until example file
 
 While(!(test-path -path "$envCommonDesktop\Example Shortcut.lnk")) {
 
                 sleep 5;
 
                 Write-Log -Message "$appVendor - $appName - $appVersion is still not finished installing, sleeping another 5" -Source $deployAppScriptFriendlyName;
 
 }
 
 ##***To Create a shortcut***
 
 New-Shortcut -Path "$envCommonPrograms\My Shortcut.lnk" `
 
     -TargetPath "$envWinDir\system32\notepad.exe" `
 
     -Arguments "--example-argument --example-argument-two" `
 
     -Description 'Notepad' `
 
     -WorkingDirectory "$envHomeDrive\$envHomePath"
 
 ## Modify ACL on a file
 
 #first load the ACL
 
 $acl_to_modify = "$envProgramData\Example\File.txt"
 $acl = Get-Acl "$acl_to_modify"
 #add another entry to the ACL list (in this case, add all users to have full control)
 $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Users", "FullControl", "None", "None", "Allow")
 $acl.SetAccessRule($ar)
 #re-write the acl on the target file
 Set-Acl "$acl_to_modify" $acl
 
 ## Modify ACL on a folder
 
 $folder_to_change = "$envSystemDrive\Example_Folder"
 $acl = Get-Acl "$folder_to_change"
 $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Users", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
 $acl.SetAccessRule($ar)
 Set-Acl "$folder_to_change" $acl  
 

##Modify ACL to registry

$acl = Get-Acl "HKLM:\SOFTWARE\Microsoft\Active Setup"
$person = [System.Security.Principal.NTAccount]"Users"          
$access = [System.Security.AccessControl.RegistryRights]"FullControl"
$inheritance = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit,ObjectInherit"
$propagation = [System.Security.AccessControl.PropagationFlags]"None"
$type = [System.Security.AccessControl.AccessControlType]"Allow"
$rule = New-Object System.Security.AccessControl.RegistryAccessRule($person,$access,$inheritance,$propagation,$type)
$acl.AddAccessRule($rule)
$acl |Set-Acl

 ## Add to environment variables (specifically PATH in this case)
 
 # The first input in the .NET code can have Path subtituted for any other environemnt variable name (gci env: to see what is presently set)
 
 $path_addition = "C:\bin"
 #add $path_addition to permanent system wide path
 [Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $path_addition, "Machine")
 #add $path_addition to permanent user specific path
 [Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $path_addition, "User")
 #add $path_addition to the process level path only (i.e. when you quit script, it will no longer be applied)
  [Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $path_addition, "Process")
 
 
 
 
 
 #.NET 4.x comparison/install
 $version_we_require = [version]"4.5.2"
 $version_we_want_path = "$dirFiles\NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
 $install_params = "/q /norestart"
 if((Get-RegistryKey "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -Value Version) -lt $version_we_require) {
 
     Write-Log -Source $deployAppScriptFriendlyName -Message ".NET version is < [string]$version_we_require, installing"
 
     Execute-Process -Path "$version_we_want_path" -Parameters "$install_params" -WaitForMSIExec:$true
  }
 
 
 
 #exit codes for reboot required
  #soft reboot <- will not 'force' restart, and sccm will progress past, but will nag to restart afterward
  Exit-Script -ExitCode 3010
  #hard reboot <- does not 'force' restart, but sccm won't proceed past any pre-reqs without reboot
  Exit-Script -ExitCode 1641
 
 ##Create Active Setup to run once per user, and run an arbitrary executable as the user
  # *WARNING* this really isn't a recommended method for a number of reasons.
  # 1. You must logoff a logged in user for them to run this
  # 2. Activesetup is not syncronous and will hold up the user login process until the command completes
  # If the executable requests user input you can prevent logins
  # 3. It's slow
  # You're better off using a scheduled task, or capturing what the executable does and doing it another way
 
 Copy-File -Path "$dirFiles\Example.exe" -Destination "$envProgramData\Example"
  Set-ActiveSetup -StubExePath "$envProgramData\Example\Example.exe" `
  -Description 'AutoDesk BIM Glue install' `
      -Key 'Autodesk_BIM_Glue_Install' `
      -ContinueOnError:$true
 
 ## Create an activesetup to run once per user, to import a .reg file
  # *WARNING* this really isn't a recommended method for a number of reasons.
  # 1. You must logoff a logged in user for them to run this
  # 2. Activesetup is not syncronous and will hold up the user login process until the command completes
  # If the executable requests user input you can prevent logins
  # 3. It's slow
  # You're better off using a scheduled task, or capturing what the executable does and doing it another way
 Copy-File -Path "$dirFiles\many_registry_keys_for_app_x.reg" -Destination "$envProgramData\Hidden\Path"

  Set-ActiveSetup -StubExePath "reg.exe IMPORT `"$envProgramData\Hidden\Path\many_registry_keys_for_app_x.reg`"" `
      -Description 'My undesirable way of applying registry keys' `
      -Key 'Undesirable_Reg_keys' `
      -ContinueOnError:$true
 
 ## function to assist finding uninstall strings, msi codes, display names of installed applications
 # paste into powershell window (or save in (powershell profile)[http://www.howtogeek.com/50236/customizing-your-powershell-profile/]
  # usage once loaded: 'Get-Uninstaller chrome'

 function Get-Uninstaller {
    [CmdletBinding()]
   param(
     [Parameter(Mandatory = $true)]
     [ValidateNotNullOrEmpty()]
     [string] $Name
    )
 
   $local_key     = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
   $machine_key32 = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
   $machine_key64 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
   $keys = @($local_key, $machine_key32, $machine_key64)
   Get-ItemProperty -Path $keys -ErrorAction 'SilentlyContinue' | ?{ ($_.DisplayName -like "*$Name*") -or ($_.PsChildName -like "*$Name*") } | Select-Object PsPath,DisplayVersion,DisplayName,UninstallString,InstallSource,InstallLocation,QuietUninstallString,InstallDate
 
 }
 
 ## end of function
 
 [scriptblock]$HKCURegistrySettings = {
  Remove-RegistryKey -Key "HKCU\Software\Microsoft\Active Setup\Installed Components\HelperObject" -SID $UserProfile.SID
} Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings
 
#Get pending rebppt

 $reboot = Get-PendingReboot
 if($reboot.IsSystemRebootPending -eq $true -or $reboot.IsCBServicingRebootPending -eq $true -or $reboot.IsWindowsUpdateRebootPending -eq $true -or $reboot.IsSCCMClientRebootPending -eq $true -or $reboot.IsFileRenameRebootPending -eq $true)
 
 { #reboot pending, cannot proceed.
     Show-InstallationPrompt -Message "A reboot is pending on this machine. Please reboot this machine first before installing $installTitle" -ButtonRightText 'OK'
      Exit-Script -ExitCode 69004 #this code to indicate a reboot is pending on this machine, and installation cannot proceed.
  }
 
 #End
  # Powershell deployment tool kit extra script
  # https://www.etdwh.com/2016/07/powershell-app-deployment-toolkit-deep-dive/

##Get Any file exists in the folder
 $UninstPath32 = Get-ChildItem -Path "C:\ProgramData\Package Cache\*" -Include windowsdesktop-runtime-3.0.*win-x86.exe -Recurse -ErrorAction SilentlyContinue
 If($UninstPath32.Exists)
 {
 Write-Log -Message "Found $($UninstPath32.FullName), now attempting to uninstall $installTitle (x86)."
 Execute-Process -Path "$UninstPath32" -Parameters "/uninstall /quiet /norestart /log C:\Windows\Logs\Software\NETDesktopRuntime30x86-Uninstall.log" -WindowStyle Hidden
 }
  ##Get the processor Architechture  
 ##AMD64
 
  If ($ENV:PROCESSOR_ARCHITECTURE -eq 'x86'){
  Write-Log -Message "Detected 32-bit OS Architecture" -Severity 1 -Source $deployAppScriptFriendlyName
 
## Microsoft Windows .NET Desktop Runtime 3.0 (x86)
$ExePath32 = Get-ChildItem -Path "$dirFiles" -Include windowsdesktop-runtime-3.0.*win-x86.exe -File -Recurse -ErrorAction SilentlyContinue
 
If($ExePath32.Exists)
{
Write-Log -Message "Found $($ExePath32.FullName), now attempting to install Microsoft Windows .NET Desktop Runtime 3.0 (x86)."
Show-InstallationProgress "Installing Microsoft Windows .NET Desktop Runtime 3.0 (x86). This may take some time. Please wait..."
Execute-Process -Path "$ExePath32" -Parameters "/install /quiet /norestart /log C:\Windows\Logs\Software\NETDesktopRuntime30x86-Install.log" -WindowStyle Hidden
}
}
 
## Get The uninstallation string for exe and uninstall silently
 $AppList = Get-InstalledApplication -Name '7-Zip'
 ForEach ($App in $AppList)
{
If($App.UninstallString)
{
$UninstPath = $App.UninstallString -replace '"', ''
If(Test-Path -Path $UninstPath)
{
Write-log -Message "Found $($App.DisplayName) ($($App.DisplayVersion)) and a valid uninstall string, now attempting to uninstall."
Execute-Process -Path $UninstPath -Parameters '/S'
Sleep -Seconds 5
}
 
}
 
}
##Run the Registries through CMD
cmd /c regedit.exe /s $dirSupportFiles\7zipFileAssoc.reg
## Install Adobe Patch only
$MspPath = Get-ChildItem -Path "$dirFiles" -Include AcroRdr*.msp -File -Recurse -ErrorAction SilentlyContinue
 
If($MspPath.Exists)
{ Write-Log -Message "Found $($MspPath.FullName), now attempting to install $installTitle."
# Install Adobe Reader DC Patch
Show-InstallationProgress "Installing Adobe Reader DC Patch. This may take some time. Please wait..."
Execute-MSI -Action Patch -Path "$MspPath"
}
### Remove the userdata through system contest
$Users = Get-ChildItem C:\Users
 
foreach ($user in $Users){
 
$StartMenuSC = "$($user.fullname)\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Amazon"
 
If (Test-Path $StartMenuSC) {
 
Remove-Item $StartMenuSC -Recurse -Force -ErrorAction SilentlyContinue
 
}
 
## Remove Kindle Desktop Shortcuts From All Profiles
 
$DesktopSC = "$($user.fullname)\Desktop\Kindle.lnk"
 
If (Test-Path $DesktopSC) {
 
Remove-Item $DesktopSC -Recurse -Force -ErrorAction SilentlyContinue
 
}
 
}
 
### Get user profile and uninstall the application if installed in user profile
$Users = Get-ChildItem C:\Users
foreach ($user in $Users){
$Anaconda = "$($user.fullname)\Anaconda"
If (Test-Path $Anaconda) {
$UninstPath = Get-ChildItem -Path "$Anaconda\*" -Include Uninstall-Anaconda.exe -Recurse -ErrorAction SilentlyContinue
If($UninstPath.Exists)
{
Write-Log -Message "Found $($UninstPath.FullName), now attempting to uninstall $installTitle."
 
Execute-ProcessAsUser -Path "$UninstPath" -Parameters "/S"
 
Get-Process -Name "Un_A" -ErrorAction SilentlyContinue | Wait-Process
 
## Cleanup Anaconda (User Profile) Directory
 
If (Test-Path $Anaconda) {
 
Write-Log -Message "Cleanup ($Anaconda) Directory."
 
Remove-Item -Path "$Anaconda" -Force -Recurse -ErrorAction SilentlyContinue
 
}
 
}
 
}
 
}

#Profiles in the machine

$UserProfiles = Get-WmiObject Win32_UserProfile | Select-Object -ExpandProperty LocalPath
 
ForEach ($Profile in $UserProfiles) {
 
if (Test-Path -Path "$envProgramFiles\NetBeans-12.9\") {
 
New-Item "$Profile\AppData\Roaming\NetBeans\12.9\config\Preferences\org\netbeans\" -ItemType Directory -Force
 
Copy-Item $Config -Destination "$Profile\AppData\Roaming\NetBeans\12.9\config\Preferences\org\netbeans\" -ErrorAction SilentlyContinue
 
}
 
}
 
##  https://silentinstallhq.com/atom-install-and-uninstall-powershell/
 
## Stop Process
 
Get-Process -Name "unins000" -ErrorAction SilentlyContinue | Wait-Process
Stop-Process -Name 'Integrator','DiskDefrag' -Force -ErrorAction SilentlyContinue
 
#Service disabled
 
Set-Service -Name 'AdskLicensingService' -StartupType 'Disabled' -ErrorAction SilentlyContinue
 
#Get the file and Uninstall the application
 
$XML = Get-ChildItem -Path "C:\ProgramData\Autodesk\ODIS\metadata\{82C320DD-8EC4-3382-A19F-1AB2019EEFCE}\" -Include bundleManifest.xml -File -Recurse -ErrorAction SilentlyContinue
 
If($XML.Exists)
{

Write-Log -Message "Found $($XML.FullName), now attempting to uninstall Autodesk AutoCAD 2022."
 
Show-InstallationProgress "Uninstalling Autodesk AutoCAD Mechanical 2022. This may take some time. Please wait..."
 
if (Test-Path -Path "$envProgramFiles\Autodesk\AdODIS\V1\Installer.exe") {
 
Execute-Process -Path "$envProgramFiles\Autodesk\AdODIS\V1\Installer.exe" -Parameters "-i uninstall -q -m C:\ProgramData\Autodesk\ODIS\metadata\{82C320DD-8EC4-3382-A19F-1AB2019EEFCE}\bundleManifest.xml" -WindowStyle Hidden -IgnoreExitCodes "1603"
 
Sleep -Seconds 5
 
}
 
}
## DIffirent uninstall older application
 
https://silentinstallhq.com/azure-batch-explorer-install-and-uninstall-powershell/

#Brave application Uninstallation
$Brave = ((Get-InstalledApplication -Name 'Brave').UninstallString -split '" ').Trim('"')
 
If ($Brave) {
 
$BraveUninst = $Brave[0]
 
$BraveParams = $Brave[1]
 
Execute-Process -Path $BraveUninst -Parameters "$BraveParams --force-uninstall" -WindowStyle Hidden -IgnoreExitCodes '20'
 
Sleep -Seconds 5
 
}
$ExePath = Get-ChildItem -Path "$dirFiles" -Include DiscordSetup.exe -File -Recurse -ErrorAction SilentlyContinue
 
If($ExePath.Exists)
 
{
 
Write-Log -Message "Found $($ExePath.FullName), now attempting to install $installTitle."
 
Show-InstallationProgress "Installing the Discord Application. This may take some time. Please wait..."
 
Execute-ProcessAsUser -Path "$ExePath" -Parameters "-s" -Wait

Get-Process -Name "DiscordSetup" -ErrorAction SilentlyContinue | Wait-Process
 
}
 
###ISS File handling  
https://silentinstallhq.com/dell-storage-manager-client-install-and-uninstall-powershell/
 
 
$Users = Get-ChildItem C:\Users
 
foreach ($user in $Users){
$DeepLLocal = "$($user.fullname)\AppData\Local\DeepL"
 
If (Test-Path $DeepLLocal) {
$UninstPath = Get-ChildItem -Path "$DeepLLocal\*" -Include Update.exe -Recurse -ErrorAction SilentlyContinue
If($UninstPath.Exists)
{}}
 
##Create a startmenu shortcut
$TargetFile = "$envProgramFiles\Eclipse\cpp-2021\eclipse\eclipse.exe"
 
$ShortcutFile = "$envAllUsersProfile\Microsoft\Windows\Start Menu\Programs\Eclipse IDE for CPP Developers.lnk"
 
$WScriptShell = New-Object -ComObject WScript.Shell
 
$Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
 
$Shortcut.TargetPath = $TargetFile
 
$Shortcut.Save()
 
#Stop more than one servuce
Stop-Process -Name 'ExpressVPN','ExpressVPNNotificationService' -Force -ErrorAction SilentlyContinue
 
$Reboot = Get-PendingReboot
 
if($Reboot.IsSystemRebootPending -eq $True -or $Reboot.IsCBServicingRebootPending -eq $True -or $Reboot.IsWindowsUpdateRebootPending -eq $True -or $Reboot.IsSCCMClientRebootPending -eq $True -or $Reboot.IsFileRenameRebootPending -eq $True)
 
{
 
## A Reboot Is Pending, Cannot Proceed Without a Restart
 
Write-Log -Message "A system restart is required before the installation of $installTitle can proceed."
 
Show-InstallationPrompt -Message "A system restart is required before the installation of $installTitle can proceed, please reboot at your earliest convenience." -ButtonRightText 'OK'
 
Exit-Script -ExitCode 69004 #This code is to indicate a reboot is pending on this machine, and the installation cannot proceed.
 
}
$GraphiQL = ((Get-InstalledApplication -Name 'GraphiQL').UninstallString -split '" ').Trim('"')

If ($GraphiQL) {
 
$GraphiQLUninst = $GraphiQL[0]
$GraphiQLParams = $GraphiQL[1]
Execute-Process -Path $GraphiQLUninst -Parameters "$GraphiQLParams /S" -WindowStyle Hidden
 
Sleep -Seconds 5
 
}
 
 
 
 ## Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
 
 ## cmd /c setx /M PATH "%PATH%;C:\Program Files (x86)\Common Files\Lenel;C:\Program Files (x86)\Acuant\SDK" | Out-Null
 
 #### Set registry to all hives in the registry
 
 Get-ChildItem -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" | ForEach-Object { Set-ItemProperty -Path $_.PSPath -Name "RegisterAdapterName" -Value "1" }
 
 ## Lap manufacturar
 
 $model = (gwmi Win32_computersystem -computername $env:COMPUTERNAME).Manufacturer
 
 $model
 

Sunday, 28 June 2020

Installed application version through PS script

$InstalledGCVer = (Get-WmiObject -Class CIM_DataFile -Filter "Name='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'" | Select-Object Version).Version

#If ($PackagedGCVer -ge $InstalledGCVer)
if ($InstalledGCVer)
{
If ([System.Version]$InstalledGCVer -gt  [System.Version]$appVersion)
{
 Show-InstallationPrompt -Message 'Newer version Google Chrome x64 '$appVersion' is already installed.' -ButtonRightText 'OK' -Icon Information -NoWait
 Write-Log -Message "Newer version Google Chrome x64 '$appVersion' is already installed."
 New-Item -Path $regpath -type Directory -Force | New-ItemProperty -Name $name -Value $value -PropertyType string -Force | Out-Null
 
}
elseif ([System.Version]$InstalledGCVer -eq  [System.Version]$appVersion)
{
 Show-InstallationPrompt -Message 'Google Chrome x64 '$appVersion' is already installed.' -ButtonRightText 'OK' -Icon Information -NoWait
 Write-Log -Message "Google Chrome x64 '$appVersion' is already installed."
 New-Item -Path $regpath -type Directory -Force | New-ItemProperty -Name $name -Value $value -PropertyType string -Force | Out-Null
}
elseif ([System.Version]$InstalledGCVer -lt  [System.Version]$appVersion)
{
    # Show Welcome Message, close Chrome if required
    Show-InstallationWelcome -CloseApps "Chrome" -silent
    # Show Progress Message (with the default message)
    Show-InstallationProgress
    Remove-MSIApplications "Google Chrome"
    Remove-MSIApplications "Google Update Helper"
}

Tuesday, 3 March 2020

All Scripts for Packaging

$registryPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Adobe\Adobe Reader\DC\FeatureLockDown"
$Name = bSuppressSignOut
$Value = 00000001
New-ItemProperty -Path $registryPath -Name $bSuppressSignOut -Value 00000001 -PropertyType DWORD -Force | Null

#------------------------------------------------------------------------------------------------------------------

#forceAccountLogonPictureFromAD:
[CmdletBinding(SupportsShouldProcess=$true)]Param()
function Test-Null($InputObject) { return !([bool]$InputObject) }

#get sid and photo for current user
$user = ([ADSISearcher]"(&(objectCategory=User)(SAMAccountName=$env:username))").FindOne().Properties
$user_photo = $user.thumbnailphoto
$user_sid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value
Write-Verbose "Updating account picture for $($user.displayname)..."

#continue if an image was returned
If ((Test-Null $user_photo) -eq $false)
{
Write-Verbose "Success. Photo exists in Active Directory."

#set up image sizes and base path
#$image_sizes = @(40, 96, 200, 240, 448) #Default Image sizes
$image_sizes = @(32, 40, 48, 96, 192, 200, 240, 448) #These extra were found in my registry
$image_mask = "Image{0}.jpg"
$image_base = $env:public + "\AccountPictures"

#set up registry
$reg_base = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\Users\{0}"
$reg_key = [string]::format($reg_base, $user_sid)
$reg_value_mask = "Image{0}"
If ((Test-Path -Path $reg_key) -eq $false) { New-Item -Path $reg_key }

#save images, set reg keys
ForEach ($size in $image_sizes)
{
#create hidden directory, if it doesn't exist
$dir = $image_base + "\" + $user_sid
If ((Test-Path -Path $dir) -eq $false) { $(mkdir $dir).Attributes = "Hidden" }

#save photo to disk, overwrite existing files
$file_name = ([string]::format($image_mask, $size))
$path = $dir + "\" + $file_name
Write-Verbose "  saving: $file_name"
$user_photo | Set-Content -Path $path -Encoding Byte -Force

#save the path in registry, overwrite existing entries
$name = [string]::format($reg_value_mask, $size)
$value = New-ItemProperty -Path $reg_key -Name $name -Value $path -Force
}

Write-Verbose "Done."
} else { Write-Error "No photo found in Active Directory for $env:username" }



#------------------------------------------------------------------------------------------------------------------------------

Execute-MSI -Action 'Install' -path "$Dirfiles\VCRT_x64\vc_runtimeMinimum_x64.msi" -parameters "/qn" -ContinueOnError:$True

Execute-MSI -Action 'Install' -path "$Dirfiles\AcroPro.msi" -Transform 'Acrobat17.mst' -parameters "/qn"

Execute-MSI -Action 'Patch' -path "$dirfiles\Acrobat2017Upd1701130096.msp"


#---------------------------------------------------------------------------------------------------------------------------------

Show-InstallationProgress -StatusMessage "Installing Adobe AIR 29.0 . . .`nInstallation may take 5 minutes to complete."


#__________________________________________________________________________________________________________________________________

Execute-process -path "taskkill.exe" -Parameters "/F /IM Bentley.Connect.Client.exe"

$RegKey = “HKLM:\SOFTWARE\Policies\Adobe\AIR”
if (-Not(Test-Path “$RegKey”)) {
New-Item -Path “$($RegKey.TrimEnd($RegKey.Split(‘\’)[-1]))” -Name “$($RegKey.Split(‘\’)[-1])” -Force | Out-Null
}
Set-ItemProperty -Path “$RegKey” -Name “UpdateDisabled” -Type Dword -Value “1”

New-Folder -Path "c:\Users\$env:username\AppData\Adobe\AIR"    

Copy-Item -Path "$dirSupportFiles\UpdateDisabled.txt" -Destination "c:\Users\$env:username\AppData\Adobe\AIR"

Rename-Item "c:\Users\$env:username\AppData\Adobe\AIR\UpdateDisabled.txt" "c:\Users\$env:username\AppData\Adobe\AIR\UpdateDisabled"

<#---------------------------------------------------------------------------------------------------------------------------------------
StopOfficeandIE.vbs  

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'iexplore.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'winword.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'excel.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'POWERPNT.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'MSOFFICE.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'MSAccess.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Notepad.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Wordpad.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'AcroRD32.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Acrobat.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'communicator.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next


#>#---------------------------------------------------------------------------------------------------------------------

Execute-Process -path 'vc_redist.x86.exe' -Parameters '/install /quiet /norestart' -IgnoreExitCodes '1638'
Execute-MSI -Action 'Install' -Path 'AGI32-19.5.msi' -Transform 'LightingAnalysts_AGI32_19.5.mst' -Parameters '/QN'
Execute-MSI -Action 'Uninstall' -Path '{812C00AF-8A83-477B-9789-8FB80FC1925E}'

#-------------------------------------------------------------------------------------------------------------------------

Execute-Process -Path "$dirFiles\AlphaCallisto.exe" -Parameters "/S -f1$Dirfiles\Install.iss"

Execute-Process -Path 'setup.exe' -Parameters '/S /f1"$Dirfiles\setup.iss"' -WindowStyle 'Hidden'


#Give Permissions to particular folder through PowerShell :


    $Alpha = "$envProgramFilesX86\Adaptive\AlphaCallisto"
    $Acl = Get-ACL $Alpha
    $AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("Users","FullControl","ContainerInherit,Objectinherit","none","Allow")
    $Acl.AddAccessRule($AccessRule)
    Set-Acl $Alpha $Acl
    Write-log " Setting folder permissions for install directory"
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


New-Folder -path '$envprogramfilesx86\HTRI'
Execute-process -path 'C:\windows\system32\icacls.exe' -parameters '"C:\Program Files (x86)\HTRI" /grant users:(OI)(CI)F /T'


#------------------------------------------------------------------------------------------------------------------------------------------------------------

Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'FLEXLM_TIMEOUT' -Type 'String' -Value '1000000'

$regkeypath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine"
 $value1 = ((Get-ItemProperty $regkeypath).'Site-Name')
 If ($value1 -like '*NA*') {
    Write-log "Configuring US License"
     Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'ARCGIS_LICENSE_FILE' -Type 'String' -Value '27004@HOULICS336'

     Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ESRI\License10.6' -Name 'LICENSE_SERVER' -Type 'String' -Value '27004@HOULICS336'
   } Else {Write-Host "NOT USA License"
 }
If ($value1 -like '*UK*') {
    Write-log "Configuring UK License"
     Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'ARCGIS_LICENSE_FILE' -Type 'String' -Value '27004@LONLICV304;27004@HOULICS336'

      Set-RegistryKey -Key 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ESRI\License10.6' -Name 'LICENSE_SERVER' -Type 'String' -Value '27004@LONLICV304;27004@HOULICS336'
   } Else {
 Write-Host "NOT UK License"
 }


#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Execute-Process -Path 'ARCHIBUS_SmartClientOnly23.2R02.404_Installer-004.exe' -Parameters '/S /v/qn'
Execute-process "Regedit.exe /s $dirSupportFiles\Office_Russia.reg"

<#----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@Echo on
REGEDIT /S "%~dp0Userdata.REG"

FOR /F "usebackq tokens=2,* skip=2" %%L IN (
`reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine" /v Site-Name`
) DO SET LOCNAME=%%M
if %LOCNAME% equ NA-Houston (
REGEDIT /S "%~dp0KBR-Houston.REG"
)
if %LOCNAME% equ AP-Jakarta (
REGEDIT /S "%~dp0KBR-Jakarta.REG"
)
New-Item "$envProgramData\RAM concept" -type directory
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\RAM concept" -Name "StubPath" -Value "$envProgramData\RAM concept\licenseReg\license.bat" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\RAM concept" -Name "Version" -Value "1,0" -Type String

#>#---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Execute-Process -Path "$dirFiles\BCompare-4.2.6.23150.exe" -Parameters "/VERYSILENT /NORESTART"
New-Folder -Path "$envAppData\Scooter Software\Beyond Compare 4"
Copy-File -Path "$dirSupportFiles\BC4Key.txt" -Destination "$envAppData\Scooter Software\Beyond Compare 4"

Execute-Process -Path 'C:\Program Files\Beyond Compare 4\unins000.exe' -Parameters '/VERYSILENT /NORESTART'

<#------------------------------------------------------------------------------------------------------------------------------------------------------------

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "beycomp_081407.exe", 9

' Give it time to load
WScript.Sleep 1000

'type in Hello World
'WshShell.SendKeys "Hello World!"
WshShell.SendKeys "{ENTER}"
#>#-----------------------------------------------------------------------------------------------------------------------------------------------------------

$PreCheck = (Get-InstalledApplication -Name 'Microsoft Visual C++ 2015 x64 Minimum Runtime')
If ($precheck.DisplayVersion -eq '14.0.24215')
{Write-log "vc++ 2015 Application already installed"}
Else
{ Write-log "Installing Microsoft Visual C++ 2015 x64 Minimum Runtime - 14.0.24215"

Execute-process -path 'vc_redist.x64.exe' -Parameters '/install /quiet /norestart' -IgnoreExitCodes '1638'
}

Execute-MSI -Action 'Install' -Path 'Bluebeam Revu x64 18.msi' -Transform 'X64_Revu_BlueBeam2018_18.1_P1.0_EN.mst' -Parameters '/QN REBOOT=ReallySuppress'

Execute-Process -Path 'BbRevu2018.2_Update2.exe' -Parameters "/silent"


#------------------------------------------------------------------------------------------------------------------------------------------------------------

https://config.office.com/    -----> to create xml file through microsoft website for all office applications


#------------------------------------------------------------------------------------------------------------------------------------------------------------
$OSVersion = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName

If($OSVersion -eq "Windows 7 Enterprise") {

 $path1 = "$envSystemDrive\Windows\System32\oobe\Info"

Set-RegistryKey -Key "HKLM:\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background" -Name "OEMBackground" -Type 'Dword' -Value '1'

$OSVersion = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName

If($OSVersion -eq "Windows 10 Enterprise") {

$WEB = "$envSystemDrive\Windows\Web\Screen\backgroundDefault.jpg"

If (test-path $WEB)
{
Remove-File -Path "$WEB" -Recurse
write-log -message "Files already exists and Removing the files"
}
Copy-Item -Path "$dirFiles\backgroundDefault.jpg" -Destination "$envSystemDrive\windows\web\Screen\" -Force

$WIN10 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization"
$img =  "$envSystemDrive\Windows\Web\Screen\backgroundDefault.jpg"

Set-ItemProperty -Path $WIN10 -Name LockScreenImage -value $img

}
#------------------------------------------------------------------------------------------------------------------------------------------------------------

@echo off
cls
echo --------------------------------------------------------
echo .
echo .
echo .      Installing VLC Media Player - Please Wait
echo .         Window will close once installed

REM Uninstall existing VLC version
if exist "%PROGRAMFILES%\VideoLAN\VLC\uninstall.exe" "%PROGRAMFILES%\VideoLAN\VLC\uninstall.exe" /S
if exist "%PROGRAMFILES(x86)%\VideoLAN\VLC\uninstall.exe" "%PROGRAMFILES% (x86)\VideoLAN\VLC\uninstall.exe" /S
:: Wait for 20 seconds
ping -n 20 127.0.0.1 > NUL

REM Run VLC Installer
"%~dp0DATA\vlc-2.2.6-win32.exe" /language=en_GB /S --no-qt-privacy-ask --no-qt-updates-notif

REM Removes VLC Desktop Icon - Windows XP
if exist "%allusersprofile%\Desktop\VLC media player.lnk" del "%allusersprofile%\Desktop\VLC media player.lnk" /S

REM Removes VLC Desktop Icon - Windows 7
if exist "%public%\Desktop\VLC media player.lnk" del "%public%\Desktop\VLC media player.lnk" /S

REM Remove all the useless shortcuts from Program Menu
if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\Documentation.lnk" del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\Documentation.lnk" /S

if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\Release Notes.lnk" del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\Release Notes.lnk" /S

if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VideoLAN Website.lnk" del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VideoLAN Website.lnk" /S

if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VLC media player - reset preferences and cache files.lnk" del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VLC media player - reset preferences and cache files.lnk" /S

if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VLC media player skinned.lnk" del "%ProgramData%\Microsoft\Windows\Start Menu\Programs\VideoLAN\VLC media player skinned.lnk" /S

REM Return exit code to SCCM
exit /B %EXIT_CODE%


------------------------------------------------------------------------------------------------------------------------------------------------------------
@ECHO OFF
:::::::::::::::::::::::::::::::::::::::::::::::
TITLE Set Custom Wallpaper for Windows 7
:
:::::::::::::::::::::::::::::::::::::::::::::::::
ECHO Set Custom Wallpaper for Windows 7:

ECHO.


:: Set script execution directory:

SET _thisdir=%~dp0

:: Take ownership of original default Wallpaper file:

TAKEOWN /F %SystemRoot%\Web\Wallpaper\Windows\img0.jpg

:: Replace ACLS for original default Wallpaper file with default inherited ACLS:

ICACLS %SystemRoot%\Web\Wallpaper\Windows\img0.jpg /reset


:: Rename original Wallpaper file so it will still be present and usable:
RENAME %SystemRoot%\Web\Wallpaper\Windows\img0.jpg imgX.jpg

:: Copy custom Wallpaper to default Wallpaper location:

XCOPY "%_thisdir%img0.jpg" "%SystemRoot%\Web\Wallpaper\Windows" /C /R /I /K /Y

:: Set Registry for Logon Wallpaper:
REG ADD HKLM\Software\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\Background /v OEMBackground /t REG_DWORD /d 1

:: Copy custom Wallpaper to Logon Wallpaper location:
mkdir "%SystemRoot%\System32\oobe\info\backgrounds"

XCOPY "%_thisdir%BackgroundDefault.jpg" "%SystemRoot%\System32\oobe\info\backgrounds" /C /R /I /K /Y


-------------------------------------------------------------------------------------------------------------------------------------------------
takeown /f c:\windows\WEB\wallpaper\Windows\img0.jpg
takeown /f C:\Windows\Web\4K\Wallpaper\Windows\*.*
icacls "c:\windows\WEB\wallpaper\Windows\img0.jpg" /E /C /G Users:(F)
icacls C:\Windows\Web\4K\Wallpaper\Windows\*.* /Grant System:(F)
del c:\windows\WEB\wallpaper\Windows\img0.jpg
del /q C:\Windows\Web\4K\Wallpaper\Windows\*.*
copy %~dp0img0.jpg c:\windows\WEB\wallpaper\Windows\img0.jpg
----------------------------------------------------------------------------------------------------------------------------------------------------

citrix reciever

Execute-process -path "$dirSupportFiles\CitrixReceiver.exe" -parameters '/SILENT /uninstall /cleanup'

Execute-process -path "CitrixReceiver.exe" -parameters '/SILENT /noreboot'

-------------------------------------------------------------------------------------------------------------------------------------------------------
Creystal report:


Execute-process -path "$Dirfiles\Setup.exe" -Parameters "-r $Dirfiles\Response.ini"

-------------------------------------------------------------------------------------------------------------------------------------------------------

Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\FLEXlm License Manager’ -Name ‘LGS_LICENSE_FILE’ -Value ‘@houlics338;@localhost‘-Type String -ContinueOnError:$False

Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Leica Geosystems\Cyclone’ -Name ‘LicServer’ -Value ‘houlics338‘-Type String -ContinueOnError:$False

Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\Leica Geosystems\Cyclone’ -Name ‘LicServers’ -Value ‘houlics338‘-Type String -ContinueOnError:$False


-------------------------------------------------------------------------------------------------------------------------------------------------------

Execute-Process -Path 'cscript.exe' -Parameters "`"$dirOffice\Office15\OSPP.VBS`" /ACT" -WindowStyle Hidden
Execute-Process -Path 'cscript.exe' -Parameters "`"$dirSupportFiles\OffScrub07.vbs`" ClientAll /S /Q /NoCancel" -WindowStyle Hidden -IgnoreExitCodes '1,2,3'

-----------------------------------------------------------------------------------------------------------------------------------------
Show-InstallationWelcome -CloseApps "excel,groove,onenote,infopath,onenote,outlook,mspub,powerpnt,winword,winproj,visio" -AllowDefer -DeferTimes 3 -CheckDiskSpace


----------------------------------------------------------------------------------------------------------------------------------------------------

Execute-Process -Path "$dirFiles\Setup.exe" -Parameters "/modify ProPlus /config `"$dirSupportFiles\AddSharePointWorkspace.xml`"" -WindowStyle Hidden


------------------------------------------------------------------------------------------------------------------------------------------------------------

If ($CurrentLoggedOnUserSession -or $CurrentConsoleUserSession -or $RunAsActiveUser) {
If (Test-Path -LiteralPath (Join-Path -Path $dirOffice -ChildPath 'Office15\OSPP.VBS') -PathType 'Leaf') {
Show-InstallationProgress -StatusMessage 'Activating Microsoft Office components. This may take some time. Please wait...'
Execute-Process -Path 'cscript.exe' -Parameters "`"$dirOffice\Office15\OSPP.VBS`" /ACT" -WindowStyle Hidden
}
}

# Prompt for a restart (if running as a user, not installing components and not running on a server)
If ((-not $addComponentsOnly) -and ($deployMode -eq 'Interactive') -and (-not $IsServerOS)) {
Show-InstallationRestartPrompt
}
}
ElseIf ($deploymentType -ieq 'Uninstall')
{

#========================================================================================================================
If ((test-path -path "C:\path\file1.txt") -and (test-path -Path "C:\path\file2.txt")) {Write-host "found both"}
$textfile = "C:\temp\$($env:Username)_$($env:USERDOMAIN)_$($env:Computername).txt"
# $network = "\\houapps442\AdminStudio\AdminStudioRepository\office users"
# Copy-Item -Path $textfile -Destination  $network -Force  
execute-process -path "Install.cmd" -parameters "/S"
#===========================================================================================================================================================
$Path = "C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\logging"
if(Test-path $Path)
{
$Path + "Exists"
Remove-Item -Path $Path -recurse

}
Else
{}
#=========================================================================================================================================================

Set-RegistryKey -Key ‘HKEY_CURRENT_USER\SOFTWARE\FLEXlm License Manager’ -Name ‘LGS_LICENSE_FILE’ -Value ‘@houlics338;@localhost‘-Type String -ContinueOnError:$False
Execute-process -path "$dirfiles\EdgeWise_v5.2_Network_Installer.exe" -Parameters '/VERYSILENT /NORESTART /LOADINF="$dirfiles\Edgewise.inf"' -WindowStyle 'Hidden'
Copy-File -Path "$dirSupportFiles\sntlconfig.xml" -Destination "$envProgramFiles\ClearEdge3D\EdgeWise\"  
#=======================================================================================================================================================

$MatlabCheck = Get-InstalledApplication -Name "MATLAB Compiler Runtime 8.2"

If ($Matlabcheck.DisplayVersion -eq "8.2") { Write-Log -Message 'Matlab Application is already installed on this device'}
Else
{ Write-Log -Message  'Installing Matlab Compiler Runtime 8.2'    

Execute-process -path "$dirfiles\bin\win64\Install.cmd" -parameters '/S' -continueOnError:$false -WindowStyle 'Hidden'}

Execute-MSI -Action 'Install' -Path 'delft3d_x64_binaries_hydro_morpho_waq.msi' -parameters '/QN'

Execute-MSI -Action 'Install' -Path 'delft3d_x64_tutorial.msi' -parameters '/QN'
#===========================================================================================================================================================

Get a list of applications matching "Drain"
$AppList = Get-InstalledApplication -Name 'Drains'
# Loop through the list, and performing the uninstall
ForEach ($App in $AppList)
{
# Check if the uninstall string exists on the entry, if not we skip.
If($App.UninstallString)
{
# Replacing " to nothing, as execute-process will fail if the path includes a "
$UninstPath = $App.UninstallString -replace '"', ''
# Check if the uninstall file exists, before we try to run it.
If(Test-Path -Path $UninstPath)
{
  # Writing status to log
  Write-log -Message "Found $($App.DisplayName) ($($App.DisplayVersion)) and valid uninstall string, trying to uninstall."
  # Running the actual uninstall.
  Execute-Process -Path $UninstPath -Parameters '/SILENT'
}
}
}
#=======================================================================================================================================================
$iniPath= "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini"

if ((test-path $inipath))
{
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'SERVER' -Key 'enablehaspc2v' -Value '0' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'SERVER' -Key 'old_files_delete_days' -Value '90' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'SERVER' -Key 'proxyconnect' -Value '0  ; 0=disabled, 1=WPAD, 2=manual' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'SERVER' -Key 'proxyhost' -Value '' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'SERVER' -Key 'proxyport' -Value '3128' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'REMOTE' -Key 'serveraddr' -Value 'PERLICS306' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'EMS' -Key 'emsurl' -Value 'http://localhost:8080' -ContinueOnError:$False
Set-IniValue -FilePath "$envCommonProgramFilesX86\aladdin Shared\HASP\hasplm.ini" -Section 'EMS' -Key 'emsurl' -Value 'http://127.0.0.1:8080' -ContinueOnError:$False
}
else{
Copy-File -Path "$dirSupportFiles\hasplm.ini" -Destination "$envCommonProgramFilesX86\aladdin Shared\HASP\" -ContinueOnError:$False
}
#===========================================================================================================================================================
Execute-process -path "$dirfiles\H2OMAPSWMM145008.exe" -parameters "/s /f1$dirfiles\setup.iss"
#==========================================================================================================================================================
Show-InstallationProgress
$AppList = Get-InstalledApplication -Name 'HTRI Xchanger Suite'

If ($AppList.DisplayVersion -eq '7.2.1')
{
Write-log 'Uninstalling HTRI 7.2.1'
Show-InstallationProgress -statusmessage "HTRI 7.2 Uninstallation "
#Remove-MSIApplications -Name 'HTRI'
Execute-process -path "$Dirfiles\Uninstall\Uninstall_7.2.1\HTRI_Xchanger\Setup.exe" -Parameters "/SUPPRESSREBOOT /NOCMDMSG -s -f1$Dirfiles\\Uninstall\Uninstall_7.2.1\HTRI_Xchanger\setup.iss"
Execute-Process -Path "$envSystemRoot\System32\cscript.exe" -Parameters "$dirFiles\Uninstall\Uninstall_7.2.1\Uninstall_ARP.vbs"
Remove-MSIApplications -Name 'HTRI'
Remove-item -Path "C:\users\public\desktop\HTRI Xchanger Suite 7.lnk"
}
ElseIf ($AppList.DisplayVersion -eq '7.3')
{
Write-log 'Uninstalling HTRI 7.3'
Show-InstallationProgress -statusmessage "HTRI 7.3 Uninstallation "
Execute-process -path "$Dirfiles\Uninstall\uninstall_7.3\Setup.exe" -Parameters "/SUPPRESSREBOOT /NOCMDMSG -s -f1$Dirfiles\\Uninstall\uninstall_7.3\setup.iss"
Remove-MSIApplications -Name 'HTRI'
Execute-MSI -Action Uninstall -Path '{06643F3D-97A5-47B3-9BDF-0D8362DBC449}'
Execute-MSI -Action Uninstall -Path '{855EF955-7EF8-4E08-A608-19AA21EE252D}'
Remove-MSIApplications -Name 'HTRI'
Execute-Process -Path "$envSystemRoot\System32\cscript.exe" -Parameters "$dirFiles\Uninstall\uninstall_7.3\Uninstall_ARP.vbs"
$InstDIR = "C:\program Files (x86)\HTRI"
Remove-Item -Force -Recurse -Path $InstDIR
Remove-Folder -Path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\HTRI"
Remove-item -Path "C:\users\public\desktop\HTRI Xchanger Suite 7.lnk"
Remove-item -Path "C:\users\public\desktop\eLibrary 2.0.6.lnk"
Remove-item -Path "C:\users\public\desktop\HTRI Website.lnk"
}
Else
{ Write-log 'No Previous versions installed'}
#========================================================================================================================================================
Execute-process -path "$Dirfiles\NDP461-KB3102436-x86-x64-AllOS-ENU.exe" -parameters '/q /norestart /log' -IgnoreExitCodes '1638'

Execute-process -path 'C:\windows\system32\icacls.exe' -parameters '"C:\Program Files (x86)\HTRI" /grant users:(OI)(CI)F /T'

start-process "cmd.exe" "/c REG Import $dirFiles\RegLicforHTRI-Win7.reg"

If ($mainExitCode -eq 3010)
 { Show-InstallationRestartPrompt -Countdownseconds 600 -CountdownNoHideSeconds 60 }


Execute-process -path "$Dirfiles\SetupHTRIXchangerSuite7.3.1.exe" -Parameters "/SUPPRESSREBOOT /NOCMDMSG -s -f1$Dirfiles\Setup_uninstall.iss"

Remove-Item -Force -Recurse -Path $InstDIR

<#========================================================================================================================================================
@ECHO OFF

SET InstallPath=%~dp0

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a:%%b)

@ECHO ================================================================================

@ECHO Installing "Uninstalling IndissPlus 3.6.4.1000"
@ECHO This install takes about 10 minutes to complete...Please be patient...
@ECHO Please do NOT close this prompt...

@ECHO ================================================================================

@ECHO This UnInstall was started at:  %mydate% %mytime%


"C:\Program Files\RSI\IndissPlus 3.6.4\uninstall.exe" /S

TIMEOUT /T 150 >nul

"C:\Program Files\RSI\Viewer 3.6.4\Uninstall.exe" /S

TIMEOUT /T 150 >nul

@if exist "%USERPROFILE%\Desktop\IndissPlus Tools.lnk" del "%USERPROFILE%\Desktop\IndissPlus Tools.lnk"

@if exist "%USERPROFILE%\Desktop\MacroExcel.lnk" del "%USERPROFILE%\Desktop\MacroExcel.lnk"


TIMEOUT /T 20 >nul


#>#==========================================================================================================================================================
Remove-RegistryKey -Key 'HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{26A24AE4-039D-4CA4-87B4-2F64180181F0}' -Name 'DeploymentFile'

<#=================================================================================================================================================
REG write VB Script :


Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WindowsFolder = WshShell.ExpandEnvironmentStrings("%systemroot%")
On error resume next
TEMP= WindowsFolder & "\"

TEMP1= "3"
tEMP2= TEMP & "Web\Wallpaper\Windows\Img0.jpg"
WshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\WallpaperStyle",TEMP1,"REG_SZ"
WshShell.RegWrite "HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",TEMP2,"REG_SZ"

#>=====================================================================================================================================================
<#====================================================================================================================================================
Start Service : VB Script
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name = 'PcaSvc'")
For Each objService in colServiceList
errReturnCode = objService.ChangeStartMode("Automatic")
Next
#>===========================================================================================================================================================
<#stop service through VB Script:

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery("Select * from Win32_Service where Name = 'PcaSvc'")

For Each objService in colServiceList

If objService.State = "Running" Then

objService.StopService()
End If
errReturnCode = objService.ChangeStartMode("Disabled")
Next
#>=================================================================================================================================================================================


Get-Process Communicator | Stop-Process
Get-Process Lync | Stop-Process
Get-Process outlook | Stop-Process
Get-Process UcMapi | Stop-Process
Get-Process msiexec.exe | Stop-Process
## Stop FontCache
Stop-ServiceAndDependencies -Name 'FontCache'
##Uninstall Lync 2010
Remove-MSIApplications -Name 'Microsoft Lync 2010' -Exact
## Uninstall Office 2010
Execute-Process -Path "cscript.exe" -Parameters "`"$dirSupportFiles\OffScrub10.vbs`" PROPLUS /S /Q /NoCancel" -WindowStyle 'Hidden' -IgnoreExitCodes '1,2,3'
##Uninstall Lync 2013
Execute-Process -Path "cscript.exe" -Parameters "`"$dirSupportFiles\OffScrub13.vbs`" LYNC /S /Q /NoCancel" -WindowStyle 'Hidden' -IgnoreExitCodes '1,2,3'

#========================================================================

Split-Path $MyInvocation.MyCommand.Path -Parent   #----->same directory in powershell
$regkeypath = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"  
$value1 = ((Get-ItemProperty $regkeypath).'CDNBaseUrl')
If (($regkeypath) -and ($value1 -like 'http://officecdn.microsoft.com/pr/b8f9b850-328d-4355-9145-c59439a0c4cf'))
Try { Set-ExecutionPolicy -ExecutionPolicy 'ByPass' -Scope 'Process' -Force -ErrorAction 'Stop' } Catch {}
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\Korean Pack" -Name "StubPath" -Value "cscript.exe /s $envProgramData\Korean Pack\ActiveSetup.bat" -Type String
Set-RegistryKey -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\Korean Pack" -Name "Version" -Value "1.0" -Type String
<#========================================================================
Set WshShell = CreateObject("WScript.Shell")

'Stop the Viewfinity Service
WshShell.Exec("""C:\Program Files\CyberArk\Endpoint Privilege Manager\Agent\vf_agent.exe"" -StopServ")
'Wait 10 seconds
WScript.Sleep(10000)

On Error Resume Next
'Remove previous Agent ID (when the agent starts up again it will generate a new one)
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Viewfinity\Agent\AgentID"

'Replace SetID
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Viewfinity\Agent\SetID","{2b8ee733-9f56-495d-b70d-6f3dbc0cc685}","REG_SZ"
'Replace DispatcherURL
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Viewfinity\Agent\DispatcherURL","http://cyberarkpd.corp.kbr.com/VFAGT/vfagent.asmx","REG_SZ"

'Start the EPM Agent Service
WshShell.Exec("net start vf_agent")
Set WshShell = Nothing



#>#=======================================================================
$AppList = ( Get-InstalledApplication -Name 'HTRI')
If ($AppList.DisplayVersion -eq "7.2.1")
{
Write-log 'Uninstalling HTRI 7.2.1'
Show-InstallationProgress -statusmessage "HTRI 7.2 Uninstallation "
Remove-MSIApplications -Name 'HTRI'
Execute-process -path "$Dirfiles\Uninstall\Uninstall_7.2.1\HTRI_Xchanger\Setup.exe" -Parameters "/SUPPRESSREBOOT /NOCMDMSG -s -f1$Dirfiles\\Uninstall\Uninstall_7.2.1\HTRI_Xchanger\setup.iss"

Execute-Process -Path "$envSystemRoot\System32\cscript.exe" -Parameters "$dirFiles\Uninstall\Uninstall_7.2.1\Uninstall_ARP.vbs"
}
#=======================================================================
$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'YOUR_APP'"
$app.Uninstall()
#---------------------------------------------------------------------------------------------------------------------------------------------------------

net use P: \\maafile300\public$   -- to map any drive
#--------------------------------------------------------------------------------------------------------------------------
$OSVersion = (get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName

If($OSVersion -eq "Windows 7 Enterprise") {
$path1 = "$envSystemDrive\Windows\System32\oobe\Info"
}
If (test-path $path1)
{
write-log -message "Folder already exists"
}
else{
New-Folder -Path "$envSystemDrive\Windows\System32\oobe\Info"
New-Folder -Path "$envSystemDrive\Windows\System32\oobe\Info\backgrounds"
}
#--------------------------------------------------------------------------------------------------------------------------
Execute-Process -Path 'wusa.exe' -Parameters "`"$($file.FullName)`" /quiet /norestart" -WindowStyle 'Hidden' -ContinueOnError $true
#--------------------------------------------------------------------------------------------------------------------------
#Enable features through powershell :

 Enable-WindowsOptionalFeature -Online -FeatureName "MSMQ-HTTP" -All
 Enable-WindowsOptionalFeature -Online -FeatureName "MSMQ-Triggers" -All
<#--------------------------------------------------------------------------------------------------------------------------
#get registry Value:
function readFromRegistry (strRegistryKey)
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )
if err.number <> 0 then
readFromRegistry= strDefault
else
readFromRegistry=value
end if
set WSHShell = nothing
end function
str = readfromRegistry("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Site-Name")
wscript.echo "sitecode is: " & str

#>#--------------------------------------------------------------------------------------------------------------------------
Execute-Process -Path 'setup.exe' -Parameters "/s /v`"ALLUSERS=1 /qn /L* \`"$configToolkitLogDir\$installName.log`"`""
Execute-ProcessAsUser -UserName 'CONTOSO\User' -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\Test\Script.ps1`"; Exit `$LastExitCode }" -Wait
Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\Test\Script.ps1`"; Exit `$LastExitCode }" -Wait
Get-IniValue -FilePath "$envProgramFilesX86\IBM\Notes\notes.ini" -Section 'Notes' -Key 'KeyFileName'
[scriptblock]$HKCURegistrySettings = {
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'qmenable' -Value 0 -Type DWord -SID $UserProfile.SID
Set-RegistryKey -Key 'HKCU\Software\Microsoft\Office\14.0\Common' -Name 'updatereliabilitydata' -Value 1 -Type DWord -SID $UserProfile.SID
}
Invoke-HKCURegistrySettingsForAllUsers -RegistrySettings $HKCURegistrySettings
New-Shortcut -Path "$envProgramData\Microsoft\Windows\Start Menu\My Shortcut.lnk" -TargetPath "$envWinDir\system32\notepad.exe" -IconLocation "$envWinDir\system32\notepad.exe"
Remove-File -Path 'C:\Windows\Downloaded Program Files\Temp.inf'
Set-IniValue -FilePath "$envProgramFilesX86\IBM\Notes\notes.ini" -Section 'Notes' -Key 'KeyFileName' -Value 'MyFile.ID'
Set-PinnedApplication -Action 'PintoStartMenu' -FilePath "$envProgramFilesX86\IBM\Lotus\Notes\notes.exe"
Set-PinnedApplication -Action 'PintoStartMenu' -FilePath "$envProgramFilesX86\IBM\Lotus\Notes\notes.exe"
Show-BalloonTip -BalloonTipText 'Installation Started' -BalloonTipTitle 'Application Name'
Show-BalloonTip -BalloonTipIcon 'Info' -BalloonTipText 'Installation Started' -BalloonTipTitle 'Application Name' -BalloonTipTime 1000
Show-DialogBox -Title 'Installed Complete' -Text 'Installation has completed. Please click OK and restart your computer.' -Icon 'Information'
Show-InstallationProgress -StatusMessage 'Installation in Progress...' -WindowLocation 'BottomRight' -TopMost $false
Show-InstallationRestartPrompt -Countdownseconds 600 -CountdownNoHideSeconds 60
Test-ServiceExists -Name 'testservice' -PassThru | Where-Object { $_ } | ForEach-Object { $_.Delete() }
Update-GroupPolicy
Set-ServiceStartMode -Name 'wuauserv' -StartMode 'Automatic (Delayed Start)'
Remove-File -LiteralPath 'C:\Windows\Downloaded Program Files' -Recurse

Test2

table {     border: 1px solid #1C6EA4;     background-color: #eeeeee;     width: 100%;     text-align: center; /* Center align all text */  ...

Search This Blog