2022-12-20 01:54:14 +00:00
|
|
|
<# ARRAYS/VARIABLES #>
|
2023-01-18 20:58:49 +00:00
|
|
|
#App to Run (as SYSTEM)
|
2023-10-31 01:53:12 +00:00
|
|
|
#$RunWait = $False if it shouldn't be waited for completion. Example:
|
2023-01-24 02:09:37 +00:00
|
|
|
#$RunSystem = "$PSScriptRoot\bins\MsiZap.exe"
|
2023-01-24 01:30:20 +00:00
|
|
|
#$RunSwitch = "tw! {GUID}"
|
2023-01-18 20:58:49 +00:00
|
|
|
$RunSystem = ""
|
2023-01-09 00:25:39 +00:00
|
|
|
$RunSwitch = ""
|
|
|
|
$RunWait = $True
|
|
|
|
|
2022-12-20 01:54:14 +00:00
|
|
|
#Beginning of Process Name to Stop - optional wildcard (*) after, without .exe, multiple: "proc1","proc2"
|
|
|
|
$Proc = @("")
|
|
|
|
|
2024-03-18 13:11:03 +00:00
|
|
|
#Beginning of Service Name to Stop - multiple: "service1.exe","service2.exe"
|
2024-03-18 13:04:23 +00:00
|
|
|
$Svc = @("")
|
|
|
|
|
2022-12-20 02:19:46 +00:00
|
|
|
#Beginning of Process Name to Wait for to End - optional wildcard (*) after, without .exe, multiple: "proc1","proc2"
|
2022-12-20 01:54:14 +00:00
|
|
|
$Wait = @("")
|
|
|
|
|
2023-02-02 23:48:38 +00:00
|
|
|
#Install App from Winget Repo, multiple: "appID1","appID2". Example:
|
|
|
|
#$WingetIDInst = @("Microsoft.PowerToys")
|
|
|
|
$WingetIDInst = @("")
|
|
|
|
|
|
|
|
#WingetID to uninstall in default manifest mode (silent if supported)
|
|
|
|
#Multiple: "ID1","ID2". Example:
|
|
|
|
#$WingetIDUninst = @("Microsoft.PowerToys")
|
|
|
|
$WingetIDUninst = @("")
|
|
|
|
|
2022-12-21 22:56:59 +00:00
|
|
|
#Beginning of App Name string to Silently Uninstall (MSI/NSIS/INNO/EXE with defined silent uninstall in registry)
|
2023-01-05 14:37:30 +00:00
|
|
|
#Multiple: "app1*","app2*", required wildcard (*) after; search is done with "-like"!
|
2023-10-31 01:53:12 +00:00
|
|
|
#Uninstall all versions if there exist several?
|
2023-02-02 23:48:38 +00:00
|
|
|
$AppUninst = @("")
|
2023-10-31 01:53:12 +00:00
|
|
|
$AllVersions = $False
|
2022-12-20 01:54:14 +00:00
|
|
|
|
|
|
|
#Beginning of Desktop Link Name to Remove - optional wildcard (*) after, without .lnk, multiple: "lnk1","lnk2"
|
|
|
|
$Lnk = @("")
|
|
|
|
|
2023-01-03 05:16:19 +00:00
|
|
|
#Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example:
|
2023-01-03 04:22:31 +00:00
|
|
|
#$AddKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
|
|
|
#$AddValue = "WAU_BypassListForUsers"
|
2023-01-03 04:29:13 +00:00
|
|
|
#$AddTypeData = "1"
|
2023-01-03 04:22:31 +00:00
|
|
|
#$AddType = "DWord"
|
|
|
|
$AddKey = ""
|
|
|
|
$AddValue = ""
|
2023-01-03 04:29:13 +00:00
|
|
|
$AddTypeData = ""
|
2023-01-03 04:22:31 +00:00
|
|
|
$AddType = ""
|
|
|
|
|
2023-01-05 07:00:41 +00:00
|
|
|
#Registry _value_ to delete in existing registry Key.
|
|
|
|
#Value can be omitted for deleting entire Key!. Example:
|
2023-01-03 04:22:31 +00:00
|
|
|
#$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
|
|
|
|
#$DelValue = "WAU_BypassListForUsers"
|
|
|
|
$DelKey = ""
|
|
|
|
$DelValue = ""
|
|
|
|
|
2023-02-02 23:48:38 +00:00
|
|
|
#Remove file/directory, multiple: "file1","file2" Example:
|
|
|
|
#$DelFile = @("${env:ProgramFiles}\PowerToys\PowerToys.Update.exe")
|
2023-01-05 05:57:37 +00:00
|
|
|
$DelFile = @("")
|
|
|
|
|
2023-02-02 23:48:38 +00:00
|
|
|
#Rename file/directory. Example:
|
|
|
|
#$RenFile = "${env:ProgramFiles}\PowerToys\PowerToys.Update.exe"
|
|
|
|
#$NewName = "PowerToys.Update.org"
|
|
|
|
$RenFile = ""
|
|
|
|
$NewName = ""
|
|
|
|
|
|
|
|
#Copy file/directory. Example:
|
2023-01-08 22:18:40 +00:00
|
|
|
#$CopyFile = "C:\Logfiles"
|
|
|
|
#$CopyTo = "C:\Drawings\Logs"
|
|
|
|
$CopyFile = ""
|
|
|
|
$CopyTo = ""
|
|
|
|
|
2023-02-02 23:48:38 +00:00
|
|
|
#Find/Replace text in file. Example:
|
2023-01-18 00:07:32 +00:00
|
|
|
#$File = "C:\dummy.txt"
|
2023-01-18 00:35:01 +00:00
|
|
|
#$FindText = 'brown fox'
|
|
|
|
#$ReplaceText = 'white fox'
|
2023-01-18 00:07:32 +00:00
|
|
|
$File = ""
|
2023-01-18 00:35:01 +00:00
|
|
|
$FindText = ''
|
|
|
|
$ReplaceText = ''
|
2023-01-17 23:53:52 +00:00
|
|
|
|
2023-01-10 22:53:15 +00:00
|
|
|
#Grant "Modify" for directory/file to "Authenticated Users" - multiple: "dir1","dir2"
|
|
|
|
$GrantPath = @("")
|
|
|
|
|
2023-01-18 20:58:49 +00:00
|
|
|
#App to Run (as current logged-on user)
|
|
|
|
$RunUser = ""
|
|
|
|
$User = $True
|
|
|
|
|
2022-12-20 01:54:14 +00:00
|
|
|
<# FUNCTIONS #>
|
2022-12-20 02:36:44 +00:00
|
|
|
. $PSScriptRoot\_Mods-Functions.ps1
|
2022-12-20 01:54:14 +00:00
|
|
|
|
|
|
|
<# MAIN #>
|
2023-01-18 20:58:49 +00:00
|
|
|
if ($RunSystem) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Invoke-ModsApp $RunSystem $RunSwitch $RunWait ""
|
2023-01-09 00:25:39 +00:00
|
|
|
}
|
2022-12-20 01:54:14 +00:00
|
|
|
if ($Proc) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Stop-ModsProc $Proc
|
|
|
|
}
|
|
|
|
if ($Svc) {
|
2024-03-18 13:22:12 +00:00
|
|
|
Stop-ModsSvc $Svc
|
2022-12-20 01:54:14 +00:00
|
|
|
}
|
|
|
|
if ($Wait) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Wait-ModsProc $Wait
|
2022-12-20 01:54:14 +00:00
|
|
|
}
|
2023-02-02 23:48:38 +00:00
|
|
|
if ($WingetIDInst) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Install-WingetID $WingetIDInst
|
2023-02-02 23:48:38 +00:00
|
|
|
}
|
|
|
|
if ($WingetIDUninst) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Uninstall-WingetID $WingetIDUninst
|
2023-02-02 23:48:38 +00:00
|
|
|
}
|
|
|
|
if ($AppUninst) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Uninstall-ModsApp $AppUninst $AllVersions
|
2022-12-20 01:54:14 +00:00
|
|
|
}
|
|
|
|
if ($Lnk) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Remove-ModsLnk $Lnk
|
2022-12-20 01:54:14 +00:00
|
|
|
}
|
2023-01-03 04:29:13 +00:00
|
|
|
if ($AddKey -and $AddValue -and $AddTypeData -and $AddType) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Add-ModsReg $AddKey $AddValue $AddTypeData $AddType
|
2023-01-03 04:22:31 +00:00
|
|
|
}
|
2023-01-05 07:00:41 +00:00
|
|
|
if ($DelKey) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Remove-ModsReg $DelKey $DelValue
|
2023-01-03 04:22:31 +00:00
|
|
|
}
|
2023-01-05 05:57:37 +00:00
|
|
|
if ($DelFile) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Remove-ModsFile $DelFile
|
2023-01-05 05:57:37 +00:00
|
|
|
}
|
2023-02-02 23:48:38 +00:00
|
|
|
if ($RenFile -and $NewName) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Rename-ModsFile $RenFile $NewName
|
2023-02-02 23:48:38 +00:00
|
|
|
}
|
2023-01-08 22:18:40 +00:00
|
|
|
if ($CopyFile -and $CopyTo) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Copy-ModsFile $CopyFile $CopyTo
|
2023-01-08 22:18:40 +00:00
|
|
|
}
|
2023-01-18 00:07:32 +00:00
|
|
|
if ($File -and $FindText -and $ReplaceText) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Edit-ModsFile $File $FindText $ReplaceText
|
2023-01-17 23:53:52 +00:00
|
|
|
}
|
2023-01-10 22:53:15 +00:00
|
|
|
if ($GrantPath) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Grant-ModsPath $GrantPath
|
2023-01-10 22:53:15 +00:00
|
|
|
}
|
2023-01-18 20:58:49 +00:00
|
|
|
if ($RunUser) {
|
2024-03-18 13:04:23 +00:00
|
|
|
Invoke-ModsApp $RunUser "" "" $User
|
2023-01-18 20:58:49 +00:00
|
|
|
}
|
2022-12-20 01:54:14 +00:00
|
|
|
|
|
|
|
<# EXTRAS #>
|