diff --git a/.github/workflows/WAU-AutoCreatePreVersion.yml b/.github/workflows/WAU-AutoCreatePreVersion.yml
deleted file mode 100644
index ba189e7..0000000
--- a/.github/workflows/WAU-AutoCreatePreVersion.yml
+++ /dev/null
@@ -1,125 +0,0 @@
----
-name: WAU - Auto Create Pre-Release Version
-
-on:
- schedule:
- - cron: "0 0 * * *"
-
-permissions:
- contents: write
-
-jobs:
- check_merged:
- name: Compare latest merge and tag
- runs-on: ubuntu-latest
- outputs:
- should_run: ${{ steps.should_run.outputs.SHOULD_RUN }}
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - name: Check if latest merged is older than latest tag
- id: should_run
- run: |
- echo "Latest tag:"
- git log --tags --pretty="%ci - %h - %s %d" -n 1
- LATEST_TAG_DATE=$(git log --tags -n 1 --pretty="%ct")
- echo $LATEST_TAG_DATE
-
- echo "Latest merge:"
- git log --merges --pretty="%ci - %h - %s %d" -n 1
- LATEST_MERGE_DATE=$(git log --merges -n 1 --pretty="%ct")
- echo $LATEST_MERGE_DATE
-
- if [[ $LATEST_MERGE_DATE -gt $LATEST_TAG_DATE ]]; then
- echo "Latest tag is older than latest merge. Nightly will be created."
- echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT
- else
- echo "Latest merge is not older than latest tag. No new release needed."
- echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT
- fi
-
- build:
- name: Create Release Asset
- needs: [check_merged]
- if: ${{ needs.check_merged.outputs.should_run == 'true' }}
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- lfs: "true"
- fetch-depth: 0
-
- - name: Auto Increment Semver Action
- uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2
- id: versioning
- with:
- releaseType: Patch
- incrementPerCommit: false
- github_token: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Next Release Number
- id: WAU_version
- run: |
- echo "Next Release version: ${{ steps.versioning.outputs.version }}"
-
- - name: Overwrite Version.txt file
- uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
- with:
- path: Sources/Winget-AutoUpdate/Version.txt
- write-mode: overwrite
- contents: ${{ steps.versioning.outputs.version }}
-
- - name: Commit & Push
- uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # v1.5
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- branch: main
- force: true
- message: "Changed version to ${{ steps.versioning.outputs.version }}"
-
- - name: Build project
- run: |
- echo "### Get MDT from Microsoft ###"
- wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi
-
- echo "### Extract MSI ###"
- 7z x MicrosoftDeploymentToolkit_x64.msi
-
- echo "### Copy ServiceUI.exe to 'Sources/Winget-AutoUpdate' folder ###"
- mv Modena_File206 Sources/Winget-AutoUpdate/ServiceUI.exe -v
-
- echo "### Go to Sources ###"
- cd Sources
-
- echo "### Zip WAU ###"
- zip -r ../WAU.zip Winget-AutoUpdate
- zip ../WAU.zip Winget-AutoUpdate-Install.ps1
-
- echo "### Zip WAU-Configurator ###"
- zip -r ../WAU-Configurator.zip Winget-AutoUpdate
- zip ../WAU-Configurator.zip "Winget-AutoUpdate-Install.ps1"
- zip ../WAU-Configurator.zip "WAU Configurator.bat"
-
- echo "### Zip ADMX ###"
- cd Policies
- zip -r ../../WAU_ADMX.zip *
- cd ../..
-
- echo "### Create install counter file ###"
- echo "Install counter file." > WAU_InstallCounter
-
- - name: Create release
- uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
- id: release
- with:
- tag: "v${{ steps.versioning.outputs.version }}"
- prerelease: true
- generateReleaseNotes: true
- name: "v${{ steps.versioning.outputs.version }} [Nightly Build]"
- artifacts: "WAU-Configurator.zip,WAU.zip,WAU_ADMX.zip,WAU_InstallCounter"
-
- - name: URL to release
- run: echo "Release -> ${{ steps.release.outputs.html_url }}"
diff --git a/.github/workflows/WAU-CreateNewVersion.yml b/.github/workflows/WAU-CreateNewVersion.yml
deleted file mode 100644
index 5149529..0000000
--- a/.github/workflows/WAU-CreateNewVersion.yml
+++ /dev/null
@@ -1,94 +0,0 @@
----
-name: WAU - Create New Version
-
-on:
- workflow_dispatch:
- inputs:
- version:
- type: choice
- default: "Patch"
- description: Select next release type
- options:
- - Patch
- - Minor
- - Major
- required: true
- pre-release:
- type: boolean
- description: Set as Pre-release version
-
-permissions:
- contents: write
-
-jobs:
- build:
- name: Create Release Asset
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- lfs: "true"
-
- - name: Auto Increment Semver Action
- uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2
- id: versioning
- with:
- releaseType: ${{ github.event.inputs.version }}
- incrementPerCommit: false
- github_token: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Overwrite Version.txt file
- uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 # v1.3
- with:
- path: Sources/Winget-AutoUpdate/Version.txt
- write-mode: overwrite
- contents: "${{ steps.versioning.outputs.version }}"
-
- - name: Commit & Push
- uses: actions-js/push@5a7cbd780d82c0c937b5977586e641b2fd94acc5 # v1.5
- with:
- github_token: ${{ secrets.GITHUB_TOKEN }}
- branch: main
- force: true
- message: "Changed version to ${{ steps.versioning.outputs.version }}"
-
- - name: Build project
- run: |
- echo "### Get MDT from Microsoft ###"
- wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi
-
- echo "### Extract MSI ###"
- 7z x MicrosoftDeploymentToolkit_x64.msi
-
- echo "### Copy ServiceUI.exe to 'Sources/Winget-AutoUpdate' folder ###"
- mv Modena_File206 Sources/Winget-AutoUpdate/ServiceUI.exe -v
-
- echo "### Go to Sources ###"
- cd Sources
-
- echo "### Zip WAU ###"
- zip -r ../WAU.zip Winget-AutoUpdate
- zip ../WAU.zip Winget-AutoUpdate-Install.ps1
-
- echo "### Zip WAU-Configurator ###"
- zip -r ../WAU-Configurator.zip Winget-AutoUpdate
- zip ../WAU-Configurator.zip "Winget-AutoUpdate-Install.ps1"
- zip ../WAU-Configurator.zip "WAU Configurator.bat"
-
- echo "### Zip ADMX ###"
- cd Policies
- zip -r ../../WAU_ADMX.zip *
- cd ../..
-
- echo "### Create install counter file ###"
- echo "Install counter file." > WAU_InstallCounter
-
- - name: Create release
- uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
- with:
- tag: "v${{ steps.versioning.outputs.version }}"
- prerelease: ${{ github.event.inputs.pre-release }}
- generateReleaseNotes: true
- name: "v${{ steps.versioning.outputs.version }}"
- artifacts: "WAU-Configurator.zip,WAU.zip,WAU_ADMX.zip,WAU_InstallCounter"
diff --git a/.github/workflows/WAU-ReleaseBuilder.yml b/.github/workflows/WAU-ReleaseBuilder.yml
new file mode 100644
index 0000000..91bf820
--- /dev/null
+++ b/.github/workflows/WAU-ReleaseBuilder.yml
@@ -0,0 +1,156 @@
+---
+name: WAU - Release builder
+
+on:
+ # To trigger nightly release (Auto)
+ schedule:
+ - cron: "0 0 * * *"
+ # To trigger stable release
+ workflow_dispatch:
+ inputs:
+ version:
+ type: choice
+ default: "Minor"
+ description: Select next release type
+ options:
+ - Patch
+ - Minor
+ - Major
+ required: true
+ pre-release:
+ type: boolean
+ description: Set as Pre-release version
+
+permissions:
+ contents: write
+
+jobs:
+ build:
+ name: Create Release
+ runs-on: windows-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ lfs: "true"
+ fetch-depth: 0
+
+ - name: Manually OR Scheduled. If Scheduled, check if release is necessary
+ run: |
+ if ("${{ github.event_name }}" -eq "schedule") {
+ echo "Latest tag:"
+ git log --tags --pretty="%ci - %h - %s %d" -n 1
+ $LATEST_TAG_DATE = git log --tags -n 1 --pretty="%ct"
+ echo $LATEST_TAG_DATE
+
+ echo "Latest merge:"
+ git log --merges --pretty="%ci - %h - %s %d" -n 1
+ $LATEST_MERGE_DATE = git log --merges -n 1 --pretty="%ct"
+ echo $LATEST_MERGE_DATE
+
+ if ( $LATEST_MERGE_DATE -gt $LATEST_TAG_DATE ) {
+ echo "Scheduled request. Latest tag is older than latest merge. Nightly prerelease will be created."
+ echo "ReleaseType=Prerelease" >> $env:GITHUB_ENV
+ }
+ else {
+ echo "Scheduled request. Latest tag is not older than latest merge. No new Nightly release needed."
+ echo "ReleaseType=No" >> $env:GITHUB_ENV
+ }
+ }
+ else {
+ echo "Manual request. Release will be created."
+ echo "ReleaseType=Release" >> $env:GITHUB_ENV
+ }
+
+ - name: Auto Increment Semver Action
+ uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2
+ if: env.ReleaseType != 'No'
+ id: versioning
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ incrementPerCommit: false
+ releaseType: Pre${{ github.event.inputs.version || 'patch'}} # Using Prepatch by default
+
+ - name: Format Semver (and msi version)
+ if: env.ReleaseType != 'No'
+ # Remove "-0" for stable release and replace by "-n" for Nightlies
+ run: |
+ $NextAutoSemver = "${{ steps.versioning.outputs.version }}"
+ if ("${{ env.ReleaseType }}" -eq "Release") {
+ $MsiVersion = $NextAutoSemver.Split("-")[0]
+ $NextSemver = $NextAutoSemver.Split("-")[0]
+ $ReleaseName = "WAU " + $NextSemver
+ $Prerelease = 0
+ }
+ else {
+ $MsiVersion = $NextAutoSemver.Split("-")[0]
+ $NextSemver = $NextAutoSemver.Replace("-0","-n")
+ $ReleaseName = "WAU " + $NextSemver + " [Nightly Build]"
+ $Prerelease = 1
+ }
+ echo "MSI version: $MsiVersion"
+ echo "Semver created: $NextSemver"
+ echo "Prerelease: $Prerelease"
+ echo "Release name: $ReleaseName"
+ echo "MsiVersion=$MsiVersion" >> $env:GITHUB_ENV
+ echo "NextSemVer=$NextSemVer" >> $env:GITHUB_ENV
+ echo "Prerelease=$Prerelease" >> $env:GITHUB_ENV
+ echo "ReleaseName=$ReleaseName" >> $env:GITHUB_ENV
+
+ - name: Build project
+ if: env.ReleaseType != 'No'
+ shell: powershell
+ run: |
+ echo "### Get MDT from Microsoft ###"
+ wget https://download.microsoft.com/download/3/3/9/339BE62D-B4B8-4956-B58D-73C4685FC492/MicrosoftDeploymentToolkit_x64.msi -UseBasicParsing -OutFile .\MicrosoftDeploymentToolkit_x64.msi
+ Start-Process .\MicrosoftDeploymentToolkit_x64.msi -ArgumentList "/quiet /norestart" -Wait
+
+ echo "### Copy ServiceUI.exe x64 to 'Sources\Winget-AutoUpdate' folder ###"
+ Copy-Item -Path "C:\Program Files\Microsoft Deployment Toolkit\Templates\Distribution\Tools\x64\ServiceUI.exe" -Destination ".\Sources\Winget-AutoUpdate\ServiceUI.exe" -Force
+ Get-Item .\Sources\Winget-AutoUpdate\*
+
+ echo "### Install WiX ###"
+ dotnet new console
+ dotnet tool install --global wix --version 5.0.1
+ wix extension add WixToolset.UI.wixext/5.0.1 -g
+ wix extension add WixToolset.Util.wixext/5.0.1 -g
+
+ echo "### Create WAU msi ###"
+ cd .\Sources\Wix\
+ wix build -src build.wxs -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -out ..\..\WAU.msi -arch x64 -d Version=${{ env.MsiVersion }} -d NextSemVer=${{ env.NextSemVer }} -d Comment="${{ env.ReleaseName }}" -d PreRelease=${{ env.PreRelease }}
+ cd ..\..
+ Get-Item .\WAU.msi
+
+ echo "### Get MSI file SHA ###"
+ $MsiSHA = (Get-FileHash .\WAU.msi).hash
+ echo " - WAU.msi SHA256: $MsiSHA"
+ echo "MSI_SHA=$MsiSHA" >> $env:GITHUB_ENV
+
+ echo "### Zip ADMX ###"
+ Compress-Archive -Path .\Sources\Policies\ADMX -DestinationPath .\WAU_ADMX.zip -Force
+ Get-Item .\*.zip
+
+ echo "### Get ADMX zip SHA ###"
+ $ADMXSHA = (Get-FileHash .\WAU_ADMX.zip).hash
+ echo " - WAU_ADMX.zip SHA256: $ADMXSHA"
+ echo "ADMX_SHA=$ADMXSHA" >> $env:GITHUB_ENV
+
+ echo "### Create install counter file ###"
+ echo "Install counter file." > WAU_InstallCounter
+
+ - name: Create release
+ uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
+ if: env.ReleaseType != 'No'
+ with:
+ tag: v${{ env.NextSemVer }}
+ prerelease: ${{ github.event.inputs.pre-release || true }}
+ generateReleaseNotes: true
+ name: ${{ env.ReleaseName }}
+ artifacts: "WAU.msi,WAU_ADMX.zip,WAU_InstallCounter"
+ body: |
+ |Files|Hash (SHA256)|Downloads|
+ |---|---|---|
+ |[WAU.msi](https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v${{ env.NextSemVer }}/WAU.msi) (x64)|${{ env.MSI_SHA }}||
+ |[WAU_ADMX.zip](https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v${{ env.NextSemVer }}/WAU_ADMX.zip)|${{ env.ADMX_SHA }}||
+
+
diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml
index be54064..e1587df 100644
--- a/.github/workflows/mega-linter.yml
+++ b/.github/workflows/mega-linter.yml
@@ -73,6 +73,7 @@ jobs:
id: cpr
if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
uses: peter-evans/create-pull-request@d121e62763d8cc35b5fb1710e887d6e69a52d3a4 # v7.0.2
+
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
diff --git a/.github/workflows/powershell-tests.yaml b/.github/workflows/powershell-tests.yaml
index e30850d..f5b89de 100644
--- a/.github/workflows/powershell-tests.yaml
+++ b/.github/workflows/powershell-tests.yaml
@@ -26,7 +26,7 @@ jobs:
- name: Perform a Pester test for WAU run
shell: powershell
run: |
- $command = New-PesterContainer -Path C:\ProgramData\Winget-AutoUpdate\user-run.ps1
+ $command = New-PesterContainer -Path "C:\Program Files\Winget-AutoUpdate\user-run.ps1"
Invoke-Pester -PassThru -Container $command -ErrorAction Continue
#- name: Read WAU Log
# id: package
diff --git a/README.md b/README.md
index 2d62ece..0b84826 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,7 @@
![image](https://github.com/Romanitho/Winget-AutoUpdate/assets/96626929/0e738c7a-cbe4-4010-94f6-1e9165bc0d49)
-[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Romanitho/Winget-AutoUpdate?label=Latest%20Stable%20Release&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest)
-[![GitHub release (by tag)](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/latest/WAU-Configurator.zip?label=Downloads&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest)
-[![GitHub release (by tag)](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/latest/WAU.zip?label=Downloads&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest)
-[![GitHub release (by tag)](https://img.shields.io/github/downloads/Romanitho/Winget-AutoUpdate/latest/WAU_InstallCounter?label=Installations&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest)
+[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Romanitho/Winget-AutoUpdate?label=Latest%20Stable%20Release&style=for-the-badge)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest)
@@ -16,29 +13,32 @@ This project uses the Winget tool to daily update apps (with system context) and
![image](https://user-images.githubusercontent.com/96626929/150645599-9460def4-0818-4fe9-819c-dd7081ff8447.png)
## Installation
-Just [download latest release (WAU-Configurator.zip)](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest/download/WAU-Configurator.zip), unzip, run "WAU Configurator":
+Just download latest release [WAU.msi](https://github.com/Romanitho/Winget-AutoUpdate/releases/latest/download/WAU.msi):
+
+![1](https://github.com/user-attachments/assets/8a3a656d-f825-4cea-b971-5f775a6c7ba8)
+![2](https://github.com/user-attachments/assets/46913e03-8604-43f5-8bca-129d1e714e45)
+
-![WAU Configurator Screenshot](https://github.com/Romanitho/Winget-AutoUpdate/assets/96626929/e3c3a331-1c49-40c5-8f70-e39cf9fc7fd1)
## Configurations
### Keep some apps out of Winget-AutoUpdate
- #### BlockList
You can exclude apps from update job (for instance, apps you want to keep at a specific version or apps with built-in auto-update):
-Add (or remove) the apps' ID you want to disable autoupdate to 'excluded_apps.txt'. (File must be placed in WAU's installation folder, or re-run install.bat).
-- #### Or AllowList
-You can update only pre-selected apps. To do so, create an "included_apps.txt" with the apps' ID of the apps you want to auto-update and run the `Winget-AutoUpdate-Install.ps1` with `-UseWhiteList` parameter. Related post:
+Add (or remove) the apps' ID you want to disable autoupdate to 'excluded_apps.txt'. (File must be placed in the same folder as WAU.msi).
+- #### AllowList
+You can update only pre-selected apps. To do so, create an "included_apps.txt" with the apps' ID of the apps you want to auto-update and place it in the same folder as WAU.msi during install.
-> The lists can contain Wildcard (*). For instance ```Mozilla.Firefox*``` will take care of all Firefox channels. (From v1.20.0)
+> The lists can contain Wildcard (*). For instance ```Mozilla.Firefox*``` will take care of all Firefox channels.
### Notification Level
-You can choose which notification will be displayed: Full, Success only or none. Use `-NotificationLevel` parameter when you run `Winget-AutoUpdate-Install.ps1`.
+You can choose which notification will be displayed: `Full`, `Success only` or `None`.
### Notification language
You can easily translate toast notifications by creating your locale xml config file (and share it with us :) ).
### When does the script run?
-WAU runs everyday at 6AM. You can now configure the frequency with `-UpdatesInterval` option (Daily, BiDaily, Weekly, BiWeekly, Monthly or Never). You can also add `-UpdatesAtLogon` parameter to run at user logon (recommended).
+WAU runs ,by default, at logon. You can configure the frequency with options (Daily, BiDaily, Weekly, BiWeekly, Monthly or Never).
### Log location
You can find logs in install location, in logs folder.
@@ -62,38 +62,32 @@ To force WAU to run on metered connections anyway, run new installation with `-R
WAU runs with system and user contexts. This way, even apps installed on User's scope are updated. Shorcuts for manually run can also be installed.
### Default install location
-By default, scripts and components will be placed in ProgramData location (inside a Winget-AutoUpdate folder). You can change this with script argument (Not Recommended).
+By default, scripts and components will be placed in "Program Files" location (inside a Winget-AutoUpdate folder).
## Update WAU
### Manual Update
Same process as new installation.
### Automatic Update
-By default, WAU AutoUpdate is enabled. It will not overwrite the configurations, icons (if personalised), excluded_apps list,...
-To disable WAU AutoUpdate, run the `Winget-AutoUpdate-Install.ps1` with `-DisableWAUAutoUpdate` parameter.
-
-## Uninstall WAU
-Simply uninstall it from your programs:
-
-![image](https://user-images.githubusercontent.com/96626929/170879336-ef034956-4778-41f0-b8fd-d307b77b70a9.png)
+By default, WAU AutoUpdate is enabled. It will not overwrite the configurations, excluded_apps list,...
## Advanced installation
**Mainly for admins or advanced user installation.**
-You can run the `Winget-AutoUpdate-Install.ps1` script with parameters :
+You can run the `WAU.msi` script with parameters :
-**-Silent**
+**/qn**
Install Winget-AutoUpdate and prerequisites silently.
-**-DoNotUpdate**
-Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation.
+**RUN_WAU**
+Default value NO. Set `RUN_WAU=YES` to run WAU just after installation.
-**-DisableWAUAutoUpdate**
-Disable Winget-AutoUpdate update checking. By default, WAU auto updates if new version is available on Github.
+**DISABLEWAUAUTOUPDATE**
+Default value 0. Set `DISABLEWAUAUTOUPDATE=1` to disable Winget-AutoUpdate self update checking. By default, WAU auto updates if new version is available on Github.
-**-UseWhiteList**
-Use White List instead of Black List. This setting will not create the "excluded_apps.txt" but "included_apps.txt".
+**USEWHITELIST**
+Set `USEWHITELIST=1` to force WAU to use WhiteList. During installation, if a whitelist is provided, this setting is automatically set to 1.
-**-ListPath**
+**LISTPATH**
Get Black/White List from external Path (**URL/UNC/Local/GPO**) - download/copy to Winget-AutoUpdate installation location if external list is newer.
**PATH** must end with a Directory, not a File...
...if the external Path is an **URL** and the web host doesn't respond with a date/time header for the file (i.e **GitHub**) then the file is always downloaded!
@@ -106,7 +100,7 @@ Instead you must escape **every** special character (notice the `%` escape too)
If `-ListPath` is set to **GPO** the Black/White List can be managed from within the GPO itself under **Application GPO Blacklist**/**Application GPO Whitelist**. Thanks to [Weatherlights](https://github.com/Weatherlights) in [#256 (reply in thread)](https://github.com/Romanitho/Winget-AutoUpdate/discussions/256#discussioncomment-4710599)!
-**-ModsPath**
+**MODSPATH**
Get Mods from external Path (**URL/UNC/Local/AzureBlob**) - download/copy to `mods` in Winget-AutoUpdate installation location if external mods are newer.
For **URL**: This requires a site directory with **Directory Listing Enabled** and no index page overriding the listing of files (or an index page with href listing of all the **Mods** to be downloaded):
```
@@ -125,58 +119,51 @@ Validated on **IIS/Apache**.
For **AzureBlob**: This requires the parameter **-AzureBlobURL** to be set with an appropriate Azure Blob Storage URL including the SAS token. See **-AzureBlobURL** for more information.
-**-AzureBlobURL**
+**AZUREBLOBURL**
Used in conjunction with the **-ModsPath** parameter to provide the Azure Storage Blob URL with SAS token. The SAS token must, at a minimum, have 'Read' and 'List' permissions. It is recommended to set the permisions at the container level and rotate the SAS token on a regular basis. Ensure the container reflects the same structure as found under the initial `mods` folder.
-**-InstallUserContext**
-Install WAU with system and **user** context executions.
+**USERCONTEXT**
+Default value 0. Set `USERCONTEXT=1` to install WAU with system and **user** context executions.
Applications installed in system context will be ignored under user context.
-**-BypassListForUsers**
-Bypass Black/White list when run in user context.
+**BYPASSLISTFORUSERS**
+Default value 0. Set `BYPASSLISTFORUSERS=1` to bypass Black/White list when run in user context.
-**-NoClean**
-Keep critical files when installing/uninstalling. This setting will keep "excluded_apps.txt", "included_apps.txt", "mods" and "logs" as they were.
+**DESKTOPSHORTCUT**
+Set `DESKTOPSHORTCUT=1` to create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate`
-**-DesktopShortcut**
-Create a shortcut for user interaction on the Desktop to run task `Winget-AutoUpdate`
+**STARTMENUSHORTCUT**
+Set `STARTMENUSHORTCUT=1` to create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate` and open Logs.
-**-StartMenuShortcut**
-Create shortcuts for user interaction in the Start Menu to run task `Winget-AutoUpdate`, open Logs and Web Help.
-
-**-NotificationLevel**
+**NOTIFICATIONLEVEL**
Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
-**-UpdatesAtLogon**
-Set WAU to run at user logon.
+**UPDATESATLOGON**
+Default value 0. Set `UPDATESATLOGON=1` to configure WAU to run at user logon.
-**-UpdatesInterval**
-Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never. Can be set to 'Never' in combination with '-UpdatesAtLogon' for instance.
+**UPDATESINTERVAL**
+Default value Never. Specify the update frequency: Daily, BiDaily, Weekly, BiWeekly, Monthly or Never.
-**-UpdatesAtTime**
-Specify the time of the update interval execution time. Default 6AM.
+**UPDATESATTIME**
+Default value 6AM. Specify the time of the update interval execution time.
-**-RunOnMetered**
-Force WAU to run on metered connections. May add cellular data costs on shared connexion from smartphone for example.
+**DONOTRUNONMETERED**
+Default value 1. Set `DONOTRUNONMETERED=0` to force WAU to run on metered connections. May add cellular data costs on shared connexion from smartphone for example.
-**-MaxLogFiles**
+**MAXLOGFILES**
Specify number of allowed log files.
Default is 3 out of 0-99:
Setting MaxLogFiles to 0 don't delete any old archived log files.
Setting it to 1 keeps the original one and just let it grow.
-**-MaxLogSize**
+**MAXLOGSIZE**
Specify the size of the log file in bytes before rotating.
Default is 1048576 = 1 MB (ca. 7500 lines)
-**-WAUinstallPath**
-Specify Winget-AutoUpdate installation location. Default: `C:\ProgramData\Winget-AutoUpdate` (Recommended to leave default).
+**INSTALLDIR**
+Specify Winget-AutoUpdate installation location. Default: `C:\Program Files\Winget-AutoUpdate` (Recommended to leave default).
-**-Uninstall**
-Remove scheduled tasks and scripts.
-## Intune/SCCM use
-See
## Custom script (Mods for WAU)
**Mods for WAU** allows you to craft a script to do whatever you like via `_WAU-mods.ps1` in the **mods** folder.
@@ -233,8 +220,5 @@ Feel free to give us any suggestions or optimizations in code and support us by
#### WAU - GitHub
[![GitHub release (release name instead of tag name)](https://img.shields.io/github/v/release/Romanitho/Winget-AutoUpdate?display_name=release&include_prereleases&label=Latest%20Release&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/)
-[![GitHub release (latest by SemVer including pre-releases)](https://img.shields.io/github/downloads-pre/Romanitho/Winget-AutoUpdate/latest/WAU-Configurator.zip?label=Downloads&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/)
-[![GitHub release (latest by SemVer including pre-releases)](https://img.shields.io/github/downloads-pre/Romanitho/Winget-AutoUpdate/latest/WAU.zip?label=Downloads&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/)
-[![GitHub release (latest by SemVer including pre-releases)](https://img.shields.io/github/downloads-pre/Romanitho/Winget-AutoUpdate/latest/WAU_InstallCounter?label=Installations&style=flat-square)](https://github.com/Romanitho/Winget-AutoUpdate/releases/)
diff --git a/Sources/WAU Configurator.bat b/Sources/WAU Configurator.bat
deleted file mode 100644
index bab4574..0000000
--- a/Sources/WAU Configurator.bat
+++ /dev/null
@@ -1,811 +0,0 @@
-@@:: This prolog allows a PowerShell script to be embedded in a .CMD file.
-@@:: Any non-PowerShell content must be preceeded by "@@"
-@@setlocal
-@@set POWERSHELL_BAT_ARGS=%*
-@@if defined POWERSHELL_BAT_ARGS set POWERSHELL_BAT_ARGS=%POWERSHELL_BAT_ARGS:"=\"%
-@@PowerShell -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command Invoke-Expression $('$args=@(^&{$args} %POWERSHELL_BAT_ARGS%);'+[String]::Join([char]10,$((Get-Content '%~f0') -notmatch '^^@@'))) & goto :EOF
-
-<#
-.SYNOPSIS
-Install and configure Winget-AutoUpdate
-
-.DESCRIPTION
-This script will:
- - Install Winget if not present
- - Install Winget-AutoUpdate to get apps daily updated
- - Install apps with Winget from a custom list file (apps.txt) or directly from popped up default list.
-#>
-
-<# UNBLOCK FILES #>
-
-Get-ChildItem -R | Unblock-File
-
-
-<# APP INFO #>
-
-# import Appx module if the powershell version is 7/core
-if ( $psversionTable.PSEdition -eq "core" ) {
- import-Module -name Appx -UseWIndowsPowershell -WarningAction:SilentlyContinue
-}
-
-$Script:WorkingDir = (Get-Location).Path
-$Script:WAUConfiguratorVersion = Get-Content "$WorkingDir\Winget-AutoUpdate\Version.txt"
-
-
-<# FUNCTIONS #>
-
-. "$WorkingDir\Winget-AutoUpdate\functions\Update-WinGet.ps1"
-. "$WorkingDir\Winget-AutoUpdate\functions\Get-WingetCmd.ps1"
-
-#Function to start or update popup
-Function Start-PopUp ($Message) {
-
- if (!$PopUpWindow) {
-
- #Create window
- $inputXML = @"
-
-
-
-
-
-"@
-
- [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
-
-
-
-
-
-
-
-
-
-"@
-
- [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- More info about WAU
-
-
-
-"@
-
- #Create window
- [xml]$XAML = ($inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^
-
-#Load assemblies
-Add-Type -AssemblyName System.Windows.Forms
-Add-Type -AssemblyName System.Drawing
-Add-Type -AssemblyName PresentationFramework
-
-#Set some variables
-$null = cmd /c ''
-[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
-$Script:ProgressPreference = "SilentlyContinue"
-$Script:ErrorActionPreference = "SilentlyContinue"
-$Script:AppToInstall = $null
-$Script:InstallWAU = $null
-$IconBase64 = [Convert]::FromBase64String("AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAMMOAADDDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39DIHd7Qx2Pdz8ec3c7FzNzOxezczcT/283E/9vNxOzbzcTQ3M7EoNzOxWDcz8QeAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA39LLNd7RyZne0Mjq39LK/+PY0f/p4Nv/7ebh/+/p5v/v6eb/7eXh/+je2f/i1s//3dDH/9zNxO7czsSd3M/GLwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4NLNEODTzIzf0sry4tbP/+3n4v/39fP//v39//////////////////////////////////38/P/39PL/7OTg/+HUzf/czcT03M7Gid3Pxw4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAODUzSrg08zM4dXN/+3m4v/7+fj/////////////////////////////////////////////////////////////////+/r5/+vk3//e0Mj/3M7FzNzPxi0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADh1s864dTN4eXb1f/38/H///////////////////////////////////////////////////////////////////////////////////////Xx7//i1s//3M7G4d7QyDoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA49bPLeLVzuHn3df/+vn4//////////////////////////////////////////////////////////////////////////////////////////////////r49//j2NH/3M/G4d3RxyoAAAAAAAAAAAAAAAAAAAAAAAAAAOLa0Q7i18/M5tzW//v5+P/////////////////////////////////+/Pr/9+ja/+/Uv//szLz/7My7/+/Sv//25tf//vv5//////////////////////////////////r49//j19D/3c/HzN/QyRAAAAAAAAAAAAAAAAAAAAAA49nSieTa0//39PL////////////////////////////+/fv/8Na+/+Ciav/XfwD/1HAA/9JoAP/RZgD/0mwA/9V5AP/dm2L/79S////9+/////////////////////7///////bz8P/f0sv/39HJjAAAAAAAAAAAAAAAAOPa0y/k2dH07+rm////////////////////////////+/Ts/+Sxhf/WeAD/1XUA/9uPPv/krnv/6cGk/+nBpP/jrXz/2ow9/9NuAP/TbwD/462E//ry6f//////9+ng/+Wzif/47OL//////+3m4f/e0Mjy3tLLNQAAAAAAAAAA5drTnejf2f/8+/v///////////////////////vz6v/ho2P/1ncA/9yQOf/u0Lb//Pbw///+/P/////////////+/P/79e7/7c61/9qLOv/SagD/3pth//348f/rzL3/zlMA/+vKuf//////+/n4/+LWz//f0sqZAAAAAOXc1B7l29Tu8evn/////////////////////////fv/5rWG/9d5AP/gnVT/+e3h////////////////////////////////////////////+Ozh/92WUf/SbAD/5bSQ/+rItf/QYQD/68q7////////////7ufj/9/Syurg08sd5tzWYOfd1//59/b///////////////////////HXv//ZgAD/3pU9//nt4f//////////////////////////////////////////////////////+Ozh/9qKOf/WfAD/3JNL/9JtAP/ry7z////////////49fP/4dXO/+HUzGPm3dag6uLd//79/f////////////////////7/6b2P/9l7AP/w07j/////////////////////////////////////////////////////////////////79K5/9V4AP/VewD/03EA/+vLvP////////////79/f/l29X/4NTMnOfd19Dv6OT////////////////////////////68Ob/89rD//779//////////////////////////////////////////////////57eP/68ar/+rFqf/ou5f/2IMa/9Z+AP/UcwD/68u7/////////////////+vj3//g1MzM6N7Y7PLt6////////////////////////////////////////////////////////////////////////////////////////////+m+lf/TaAD/1G8A/9RwAP/WdwD/1XYA/9NsAP/tzrz/////////////////7+nl/+HVzezo39n/9PDu////////////////////////////////////////////////////////////////////////////////////////////+e7k/+3Puv/tzrz/7c28/+3NvP/szbv/7s+8//vz6//////////////////y7On/4tXO/+ng2v/18e7//////////////////PXs//HVvf/v0rz/79K8/+/SvP/v0bz/79K6//rv5f////////////////////////////////////////////////////////////////////////////////////////////Lt6v/i18//6eHb7PPv7P/////////////////x1bz/3IgA/92MAP/diwD/24UA/9uCAP/ZewD/68OX////////////////////////////////////////////////////////////////////////////////////////////8Orn/+PX0Ozq4dzM8ezo//////////////////DTvP/ekAD/35YQ/+CYJP/sxJr/7syr/+7Mrf/57uP//////////////////////////////////////////////////vv3//LZw//67+b////////////////////////////t5uH/5NjS0Ovi3Zzu5+P//v7+////////////8dS8/9+SAP/glgD/35MA//LZvP/////////////////////////////////////////////////////////////////w07j/2HkA/+m8jv////7//////////////////v39/+ng2v/l2tOg7OTfY+zk4P/7+Pf////////////x1bz/35IA/+WqU//hmQb/46JA//rv4v//////////////////////////////////////////////////////+e7i/9+ZPv/agwD/8de////////////////////////59/X/5tzW/+Xb1WDs5OAd7OTf6vXw7v////////////HVvP/fjwD/8NO2/+zDlP/fkAD/5qxZ//rw4v////////////////////////////////////////////ru4v/ipFb/2oIA/+i3h////fv///////////////////////Hs6P/m3NXu5dzVHgAAAADs5eCZ7ufj//38+///////8dW6/96KAP/x1r7//fry/+eyaP/fkAD/5KRD//LXuP/89+/////9//////////////79//z38f/x1bj/4Zw9/9uFAP/kqmX/+/Tq///////////////////////8/Pv/6uHc/+bd150AAAAAAAAAAO3m4jXt5eHx9fHu///////68OT/7caQ//nu4f///////PXr/+vAif/glQD/35IA/+SlRv/qvYH/7sum/+7Lpv/pu4D/4qBE/92LAP/djAD/6bqI//z17P////////////////////////////Ls6f/n3df0593XLwAAAAAAAAAAAAAAAO3n44zu5+P/+vj3//////////////////////////////78//Tewv/os2n/4ZsA/9+RAP/ejAD/3YoA/96PAP/glwD/57Fu//PbwP///fz////////////////////////////49vT/6eDb/+nf2YkAAAAAAAAAAAAAAAAAAAAA7OnjEO7n48zw6uf//Pv7//////////////////////////////////78+f/57Nr/89zB//HVvP/x1bz/89zB//ns3P/+/fr//////////////////////////////////Pr5/+zl4P/p4NrM6ODYDgAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlKe7n4+Dx6+j//Pv7//////////////////////////////////////////////////////////////////////////////////////////////////z7+v/u5+L/6eHb4evi2ywAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7+nlOu/o5OHx6+j/+vj3///////////////////////////////////////////////////////////////////////////////////////59/b/7ufi/+ri3eDr4906AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8OrmLO/p5czw6eb/9vLw//38/P/////////////////////////////////////////////////////////////////9/Pv/9PDt/+zl4P/r497M6+XeKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8enpDvDq5onv6eX08ezo//by8P/7+vn//v7+//////////////////////////////////7+/v/7+fj/9fHv/+7o4//s5ODx7OTgjOvj3xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPHq5i/w6uWc7+nl7vDq5v/y7On/9PDt//bz8P/39PL/9/Ty//by8P/07+z/8Orn/+7n4//t5uHq7OXhmezl4TUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADw6+Ue8OrmYO/p5aDv6eXQ7+jl7O/o5P/u6OT/7ujk7O7n48zu5+Kc7efjY+zl5B0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/8AD//8AAP/8AAA/+AAAH/AAAA/gAAAHwAAAA8AAAAOAAAABgAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAGAAAABwAAAA8AAAAPgAAAH8AAAD/gAAB/8AAA//wAA///AA/8=")
-
-Start-PopUp "Starting..."
-
-#Check if WAUConfigurator is uptodate
-Get-WAUConfiguratorLatestVersion
-
-#Check if Winget is installed, and install if not
-$null = Update-WinGet
-
-#Get WinGet cmd
-$Script:Winget = Get-WingetCmd
-
-#Run WAUConfigurator
-Close-PopUp
-Start-InstallGUI
diff --git a/Sources/Winget-AutoUpdate-Install.ps1 b/Sources/Winget-AutoUpdate-Install.ps1
deleted file mode 100644
index c1d3620..0000000
--- a/Sources/Winget-AutoUpdate-Install.ps1
+++ /dev/null
@@ -1,514 +0,0 @@
-<#
-.SYNOPSIS
-Configure Winget to daily update installed apps.
-
-.DESCRIPTION
-Install powershell scripts and scheduled task to daily run Winget upgrade and notify connected users.
-Posibility to exclude apps from auto-update
-https://github.com/Romanitho/Winget-AutoUpdate
-
-.PARAMETER Silent
-Install Winget-AutoUpdate and prerequisites silently
-
-.PARAMETER MaxLogFiles
-Specify number of allowed log files (Default is 3 of 0-99: Setting MaxLogFiles to 0 don't delete any old archived log files, 1 keeps the original one and just let it grow)
-
-.PARAMETER MaxLogSize
-Specify the size of the log file in bytes before rotating. (Default is 1048576 = 1 MB)
-
-.PARAMETER WAUinstallPath
-Specify Winget-AutoUpdate installation localtion. Default: C:\ProgramData\Winget-AutoUpdate\
-
-.PARAMETER DoNotUpdate
-Do not run Winget-AutoUpdate after installation. By default, Winget-AutoUpdate is run just after installation.
-
-.PARAMETER DisableWAUAutoUpdate
-Disable Winget-AutoUpdate update checking. By default, WAU auto update if new version is available on Github.
-
-.PARAMETER UseWhiteList
-Use White List instead of Black List. This setting will not create the "exclude_apps.txt" but "include_apps.txt"
-
-.PARAMETER ListPath
-Get Black/White List from Path (URL/UNC/GPO/Local)
-
-.PARAMETER ModsPath
-Get mods from Path (URL/UNC/Local/AzureBlob)
-
-.PARAMETER AzureBlobURL
-Set the Azure Storage Blob URL including the SAS token. The token requires at a minimum 'Read' and 'List' permissions. It is recommended to set this at the container level
-
-.PARAMETER Uninstall
-Remove scheduled tasks and scripts.
-
-.PARAMETER NoClean
-Keep critical files when installing/uninstalling
-
-.PARAMETER DesktopShortcut
-Create a shortcut for user interaction on the Desktop to run task "Winget-AutoUpdate"
-
-.PARAMETER StartMenuShortcut
-Create shortcuts for user interaction in the Start Menu to run task "Winget-AutoUpdate", open Logs and Web Help
-
-.PARAMETER NotificationLevel
-Specify the Notification level: Full (Default, displays all notification), SuccessOnly (Only displays notification for success) or None (Does not show any popup).
-
-.PARAMETER UpdatesAtLogon
-Set WAU to run at user logon.
-
-.PARAMETER UpdatesInterval
-Specify the update frequency: Daily (Default), BiDaily, Weekly, BiWeekly, Monthly or Never
-
-.PARAMETER UpdatesAtTime
-Specify the time of the update interval execution time. Default 6AM
-
-.PARAMETER RunOnMetered
-Run WAU on metered connection. Default No.
-
-.PARAMETER InstallUserContext
-Install WAU with system and user context executions
-
-.PARAMETER BypassListForUsers
-Configure WAU to bypass the Black/White list when run in user context. Applications installed in system context will be ignored under user context.
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -DoNotUpdate -MaxLogFiles 4 -MaxLogSize 2097152
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -UseWhiteList
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -ListPath https://www.domain.com/WAULists -StartMenuShortcut -UpdatesInterval BiDaily
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -ModsPath https://www.domain.com/WAUMods -DesktopShortcut -UpdatesInterval Weekly
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -UpdatesAtLogon -UpdatesInterval Weekly
-
-.EXAMPLE
-.\Winget-AutoUpdate-Install.ps1 -Silent -Uninstall -NoClean
-
-#>
-
-[CmdletBinding()]
-param(
- [Parameter(Mandatory = $False)] [Alias('S')] [Switch] $Silent = $false,
- [Parameter(Mandatory = $False)] [Alias('Path', 'WingetUpdatePath')] [String] $WAUinstallPath = "$env:ProgramData\Winget-AutoUpdate",
- [Parameter(Mandatory = $False)] [Alias('List')] [String] $ListPath,
- [Parameter(Mandatory = $False)] [Alias('Mods')] [String] $ModsPath,
- [Parameter(Mandatory = $False)] [Alias('AzureBlobURL')] [String] $AzureBlobSASURL,
- [Parameter(Mandatory = $False)] [Switch] $DoNotUpdate = $false,
- [Parameter(Mandatory = $False)] [Switch] $DisableWAUAutoUpdate = $false,
- [Parameter(Mandatory = $False)] [Switch] $RunOnMetered = $false,
- [Parameter(Mandatory = $False)] [Switch] $Uninstall = $false,
- [Parameter(Mandatory = $False)] [Switch] $NoClean = $false,
- [Parameter(Mandatory = $False)] [Switch] $DesktopShortcut = $false,
- [Parameter(Mandatory = $False)] [Switch] $StartMenuShortcut = $false,
- [Parameter(Mandatory = $False)] [Switch] $UseWhiteList = $false,
- [Parameter(Mandatory = $False)] [ValidateSet("Full", "SuccessOnly", "None")] [String] $NotificationLevel = "Full",
- [Parameter(Mandatory = $False)] [Switch] $UpdatesAtLogon = $false,
- [Parameter(Mandatory = $False)] [ValidateSet("Daily", "BiDaily", "Weekly", "BiWeekly", "Monthly", "Never")] [String] $UpdatesInterval = "Daily",
- [Parameter(Mandatory = $False)] [DateTime] $UpdatesAtTime = ("06am"),
- [Parameter(Mandatory = $False)] [Switch] $BypassListForUsers = $false,
- [Parameter(Mandatory = $False)] [Switch] $InstallUserContext = $false,
- [Parameter(Mandatory = $False)] [ValidateRange(0, 99)] [int32] $MaxLogFiles = 3,
- [Parameter(Mandatory = $False)] [int64] $MaxLogSize = 1048576 # in bytes, default is 1048576 = 1 MB
-)
-
-
-<# FUNCTIONS #>
-
-#Include external Functions
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Install-Prerequisites.ps1"
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Invoke-DirProtect.ps1"
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Update-WinGet.ps1"
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Update-StoreApps.ps1"
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Add-Shortcut.ps1"
-. "$PSScriptRoot\Winget-AutoUpdate\functions\Write-ToLog.ps1"
-
-
-function Install-WingetAutoUpdate {
-
- Write-ToLog "Installing WAU $WAUVersion..." "Yellow"
-
- try {
- #Copy files to location
- if (!(Test-Path "$WAUinstallPath\Winget-Upgrade.ps1")) {
- Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> Running fresh installation..."
- }
- elseif ($NoClean) {
- #Keep critical files
- Get-ChildItem -Path $WAUinstallPath -Exclude *.txt, mods, logs, icons | Remove-Item -Recurse -Force
- Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Exclude icons -Recurse -Force -ErrorAction SilentlyContinue #Exclude icons if personalized
- Write-ToLog "-> Updating previous installation. Keeping critical existing files..."
- }
- else {
- #Keep logs only
- Get-ChildItem -Path $WAUinstallPath -Exclude logs | Remove-Item -Recurse -Force
- Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> Updating previous installation..."
- }
-
- #White List or Black List apps
- if ($UseWhiteList) {
- #If fresh install and "included_apps.txt" exists, copy the list to WAU
- if ((!$NoClean) -and (Test-Path "$PSScriptRoot\included_apps.txt")) {
- Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> Copied a brand new Whitelist."
- }
- #Else, only copy the "included_apps.txt" list if not existing in WAU
- elseif (!(Test-Path "$WAUinstallPath\included_apps.txt")) {
- Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> No Whitelist was existing. Copied from install sources."
- }
- }
- else {
- if (!$NoClean) {
- Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> Copied brand new Blacklist."
- }
- elseif (!(Test-Path "$WAUinstallPath\excluded_apps.txt")) {
- Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
- Write-ToLog "-> No Blacklist was existing. Copied from install sources."
- }
- }
-
- # Set dummy regkeys for notification name and icon
- & reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v DisplayName /t REG_EXPAND_SZ /d "Application Update" /f | Out-Null
- & reg add "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /v IconUri /t REG_EXPAND_SZ /d %SystemRoot%\system32\@WindowsUpdateToastIcon.png /f | Out-Null
-
- # Clean potential old install
- Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
-
- # Settings for the scheduled task for Updates (System)
- Write-ToLog "-> Installing WAU scheduled tasks"
- $taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WAUinstallPath)\winget-upgrade.ps1`""
- $taskTriggers = @()
- if ($UpdatesAtLogon) {
- $tasktriggers += New-ScheduledTaskTrigger -AtLogOn
- }
- if ($UpdatesInterval -eq "Daily") {
- $tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime
- }
- elseif ($UpdatesInterval -eq "BiDaily") {
- $tasktriggers += New-ScheduledTaskTrigger -Daily -At $UpdatesAtTime -DaysInterval 2
- }
- elseif ($UpdatesInterval -eq "Weekly") {
- $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2
- }
- elseif ($UpdatesInterval -eq "BiWeekly") {
- $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 2
- }
- elseif ($UpdatesInterval -eq "Monthly") {
- $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 4
- }
- $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
- # Set up the task, and register it
- if ($taskTriggers) {
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTriggers
- }
- else {
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
- }
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
-
- # Settings for the scheduled task in User context
- $taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\winget-upgrade.ps1`"`""
- $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
- # Set up the task for user apps
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
-
- # Settings for the scheduled task for Notifications
- $taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\winget-notify.ps1`"`""
- $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
- # Set up the task, and register it
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
-
- # Settings for the GPO scheduled task
- $taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WAUinstallPath)\WAU-Policies.ps1`""
- $tasktrigger = New-ScheduledTaskTrigger -Daily -At 6am
- $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
- # Set up the task, and register it
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Policies' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
-
- #Set task readable/runnable for all users
- $scheduler = New-Object -ComObject "Schedule.Service"
- $scheduler.Connect()
- $task = $scheduler.GetFolder("WAU").GetTask("Winget-AutoUpdate")
- $sec = $task.GetSecurityDescriptor(0xF)
- $sec = $sec + '(A;;GRGX;;;AU)'
- $task.SetSecurityDescriptor($sec, 0)
-
- # Configure Reg Key
- Write-ToLog "-> Setting Registry config"
- New-Item $regPath -Force | Out-Null
- New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force | Out-Null
- New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force | Out-Null
- New-ItemProperty $regPath -Name DisplayVersion -Value $WAUVersion -Force | Out-Null
- New-ItemProperty $regPath -Name InstallLocation -Value $WAUinstallPath -Force | Out-Null
- New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
- New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WAUinstallPath\WAU-Uninstall.ps1`"" -Force | Out-Null
- New-ItemProperty $regPath -Name NoModify -Value 1 -Force | Out-Null
- New-ItemProperty $regPath -Name NoRepair -Value 1 -Force | Out-Null
- New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force | Out-Null
- New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $NotificationLevel -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_PostUpdateActions -Value 0 -PropertyType DWord -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value $MaxLogFiles -PropertyType DWord -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_MaxLogSize -Value $MaxLogSize -PropertyType DWord -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_UpdatesAtTime -Value $UpdatesAtTime -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_UpdatesInterval -Value $UpdatesInterval -Force | Out-Null
- if ($UpdatesAtLogon) {
- New-ItemProperty $regPath -Name WAU_UpdatesAtLogon -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if ($DisableWAUAutoUpdate) {
- New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force | Out-Null
- }
- if ($UseWhiteList) {
- New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if (!$RunOnMetered) {
- New-ItemProperty $regPath -Name WAU_DoNotRunOnMetered -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if ($ListPath) {
- New-ItemProperty $regPath -Name WAU_ListPath -Value $ListPath -Force | Out-Null
- }
- if ($ModsPath) {
- New-ItemProperty $regPath -Name WAU_ModsPath -Value $ModsPath -Force | Out-Null
- }
- if ($AzureBlobSASURL) {
- New-ItemProperty $regPath -Name WAU_AzureBlobSASURL -Value $AzureBlobSASURL -Force | Out-Null
- }
- if ($BypassListForUsers) {
- New-ItemProperty $regPath -Name WAU_BypassListForUsers -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if ($InstallUserContext) {
- New-ItemProperty $regPath -Name WAU_UserContext -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if ($DesktopShortcut) {
- New-ItemProperty $regPath -Name WAU_DesktopShortcut -Value 1 -PropertyType DWord -Force | Out-Null
- }
- if ($StartMenuShortcut) {
- New-ItemProperty $regPath -Name WAU_StartMenuShortcut -Value 1 -PropertyType DWord -Force | Out-Null
- }
-
- #Security check
- Write-ToLog "-> Checking Mods Directory:"
- $Protected = Invoke-DirProtect "$WAUinstallPath\mods"
- if ($Protected -eq $True) {
- Write-ToLog " The mods directory is secured!" "Cyan"
- }
- else {
- Write-ToLog " Error: The mods directory couldn't be verified as secured!" "Red"
- }
- Write-ToLog "-> Checking Functions Directory:"
- $Protected = Invoke-DirProtect "$WAUinstallPath\Functions"
- if ($Protected -eq $True) {
- Write-ToLog " The Functions directory is secured!" "Cyan"
- }
- else {
- Write-ToLog " Error: The Functions directory couldn't be verified as secured!" "Red"
- }
-
- #Create Shortcuts
- if ($StartMenuShortcut) {
- if (!(Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
- New-Item -ItemType Directory -Force -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" | Out-Null
- }
- Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Check for updated Apps.lnk" "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\user-run.ps1`"`"" "${env:SystemRoot}\System32\shell32.dll,-16739" "Manual start of Winget-AutoUpdate (WAU)..."
- Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Open logs.lnk" "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\user-run.ps1`" -Logs`"" "${env:SystemRoot}\System32\shell32.dll,-16763" "Open existing WAU logs..."
- Add-Shortcut "wscript.exe" "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)\WAU - Web Help.lnk" "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\user-run.ps1`" -Help`"" "${env:SystemRoot}\System32\shell32.dll,-24" "Help for WAU..."
- }
-
- if ($DesktopShortcut) {
- Add-Shortcut "wscript.exe" "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" "`"$($WAUinstallPath)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUinstallPath)\user-run.ps1`"`"" "${env:SystemRoot}\System32\shell32.dll,-16739" "Manual start of Winget-AutoUpdate (WAU)..."
- }
-
- #Add 1 to counter file
- try {
- Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUVersion)/WAU_InstallCounter" | Out-Null
- }
- catch {
- Write-ToLog "-> Not able to report installation." "Yellow"
- }
-
- Write-ToLog "-> WAU Installation succeeded!`n" "Green"
- Start-sleep 1
-
- #Run Winget ?
- Start-WingetAutoUpdate
- }
- catch {
- Write-ToLog "-> WAU Installation failed! Error $_ - Try running me with admin rights.`n" "Red"
- Start-sleep 1
- return $False
- }
-}
-
-function Uninstall-WingetAutoUpdate {
-
- Write-ToLog "Uninstalling WAU started!" "Yellow"
-
- #Get registry install location
- $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation -ErrorAction SilentlyContinue
-
- #Check if installed location exists and delete
- if ($InstallLocation) {
-
- try {
- if (!$NoClean) {
- Write-ToLog "-> Removing files and config."
- Get-ChildItem -Path $InstallLocation -Exclude logs | Remove-Item -Force -Recurse
- if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") {
- Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null
- }
- if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") {
- Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null
- }
- }
- else {
- #Keep critical files
- Write-ToLog "-> Removing files. Keeping config."
- Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
- }
- & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
- & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
-
- if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
- Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null
- }
-
- if ((Test-Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk")) {
- Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null
- }
-
- Write-ToLog "-> Removing scheduled tasks."
- Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
-
- Write-ToLog "Uninstallation succeeded!`n" "Green"
- Start-sleep 1
- }
- catch {
- Write-ToLog "Uninstallation failed! Run as admin ?`n" "Red"
- Start-sleep 1
- }
- }
- else {
- Write-ToLog "WAU is not installed!`n" "Red"
- Start-sleep 1
- }
-}
-
-function Start-WingetAutoUpdate {
- #If -DoNotUpdate is true, skip.
- if (!($DoNotUpdate)) {
- #If -Silent, run Winget-AutoUpdate now
- if ($Silent) {
- $RunWinget = $True
- }
- #Ask for WingetAutoUpdate
- else {
- $MsgBoxTitle = "Winget-AutoUpdate"
- $MsgBoxContent = "Would you like to run Winget-AutoUpdate now?"
- $MsgBoxTimeOut = 60
- $MsgBoxReturn = (New-Object -ComObject "Wscript.Shell").Popup($MsgBoxContent, $MsgBoxTimeOut, $MsgBoxTitle, 4 + 32)
- if ($MsgBoxReturn -ne 7) {
- $RunWinget = $True
- }
- }
- if ($RunWinget) {
- try {
- Write-ToLog "Running Winget-AutoUpdate..." "Yellow"
- Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Start-ScheduledTask -ErrorAction SilentlyContinue
- while ((Get-ScheduledTask -TaskName "Winget-AutoUpdate").State -ne 'Ready') {
- Start-Sleep 1
- }
- }
- catch {
- Write-ToLog "Failed to run Winget-AutoUpdate..." "Red"
- }
- }
- }
- else {
- Write-ToLog "Skip running Winget-AutoUpdate"
- }
-}
-
-
-<# APP INFO #>
-
-$WAUVersion = Get-Content "$PSScriptRoot\Winget-AutoUpdate\Version.txt" -ErrorAction SilentlyContinue
-
-
-<# MAIN #>
-
-#If running as a 32-bit process on an x64 system, re-launch as a 64-bit process
-if ("$env:PROCESSOR_ARCHITEW6432" -ne "ARM64") {
- if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe") {
- Start-Process "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -Wait -NoNewWindow -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command $($MyInvocation.line)"
- Exit $lastexitcode
- }
-}
-
-#Config console output encoding
-$null = cmd /c '' #Tip for ISE
-[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
-
-# Workaround for ARM64 (Access Denied / Win32 internal Server error)
-$Script:ProgressPreference = 'SilentlyContinue'
-
-#Set install log file
-$Script:LogFile = "$WAUinstallPath\logs\WAU-Installer.log"
-
-Write-Host "`n "
-Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d8b 888 d88P888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d888b 888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888d88888b888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 88888P Y88888 d88P 888 888 888" -ForegroundColor Cyan
-Write-Host "`t 8888P Y8888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta
-Write-Host "`t Winget-AutoUpdate $WAUVersion`n" -ForegroundColor Cyan
-Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
-Write-Host "`t________________________________________________________`n"
-
-#Define WAU registry key
-$Script:regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
-
-if (!$Uninstall) {
- Write-ToLog " INSTALLING WAU" -LogColor "Cyan" -IsHeader
- Install-Prerequisites
- $UpdateWinget = Update-Winget
- if ($UpdateWinget -ne "fail") {
- Install-WingetAutoUpdate
- }
- else {
- Write-ToLog "Winget is mandatory to execute WAU." "Red"
- }
-}
-else {
- Write-ToLog " UNINSTALLING WAU" -LogColor "Cyan" -IsHeader
- Uninstall-WingetAutoUpdate
-}
-
-if (Test-Path "$WAUinstallPath\Version.txt") {
- Remove-Item "$WAUinstallPath\Version.txt" -Force
-}
-
-Write-ToLog "End of process." "Cyan"
-Start-Sleep 3
diff --git a/Sources/Winget-AutoUpdate/Invisible.vbs b/Sources/Winget-AutoUpdate/Invisible.vbs
deleted file mode 100644
index c95e6b6..0000000
--- a/Sources/Winget-AutoUpdate/Invisible.vbs
+++ /dev/null
@@ -1 +0,0 @@
-CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, True
diff --git a/Sources/Winget-AutoUpdate/User-Run.ps1 b/Sources/Winget-AutoUpdate/User-Run.ps1
index 176fb26..094e132 100644
--- a/Sources/Winget-AutoUpdate/User-Run.ps1
+++ b/Sources/Winget-AutoUpdate/User-Run.ps1
@@ -3,26 +3,13 @@
Handle user interaction from shortcuts and show a Toast notification
.DESCRIPTION
-Act on shortcut run (DEFAULT: Check for updated Apps)
-
-.PARAMETER Logs
-Open the Log file from Winget-AutoUpdate installation location
-
-.PARAMETER Help
-Open the Web Help page
-https://github.com/Romanitho/Winget-AutoUpdate
+Act on shortcut run
.EXAMPLE
-.\user-run.ps1 -Logs
+.\user-run.ps1
#>
-[CmdletBinding()]
-param(
- [Parameter(Mandatory = $False)] [Switch] $Logs = $false,
- [Parameter(Mandatory = $False)] [Switch] $Help = $false
-)
-
function Test-WAUisRunning {
If (((Get-ScheduledTask -TaskName 'Winget-AutoUpdate').State -eq 'Running') -or ((Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext').State -eq 'Running')) {
Return $True
@@ -45,58 +32,42 @@ Get-NotifLocale
$OnClickAction = "$WorkingDir\logs\updates.log"
$Button1Text = $NotifLocale.local.outputs.output[11].message
-if ($Logs) {
- if (Test-Path "$WorkingDir\logs\updates.log") {
- Invoke-Item "$WorkingDir\logs\updates.log"
+try {
+ #Check if WAU is currently running
+ if (Test-WAUisRunning) {
+ $Message = $NotifLocale.local.outputs.output[8].message
+ $MessageType = "warning"
+ Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
+ break
+ }
+ #Run scheduled task
+ Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop
+ #Starting check - Send notification
+ $Message = $NotifLocale.local.outputs.output[6].message
+ $MessageType = "info"
+ Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
+ #Sleep until the task is done
+ While (Test-WAUisRunning) {
+ Start-Sleep 3
+ }
+
+ #Test if there was a list_/winget_error
+ if (Test-Path "$WorkingDir\logs\error.txt") {
+ $MessageType = "error"
+ $Critical = Get-Content "$WorkingDir\logs\error.txt" -Raw
+ $Critical = $Critical.Trim()
+ $Critical = $Critical.Substring(0, [Math]::Min($Critical.Length, 50))
+ $Message = "Critical:`n$Critical..."
}
else {
- #Not available yet
- $Message = $NotifLocale.local.outputs.output[5].message
- $MessageType = "warning"
- Start-NotifTask -Message $Message -MessageType $MessageType -UserRun
+ $MessageType = "success"
+ $Message = $NotifLocale.local.outputs.output[9].message
}
+ Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
}
-elseif ($Help) {
- Start-Process "https://github.com/Romanitho/Winget-AutoUpdate"
-}
-else {
- try {
- #Check if WAU is currently running
- if (Test-WAUisRunning) {
- $Message = $NotifLocale.local.outputs.output[8].message
- $MessageType = "warning"
- Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
- break
- }
- #Run scheduled task
- Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction Stop | Start-ScheduledTask -ErrorAction Stop
- #Starting check - Send notification
- $Message = $NotifLocale.local.outputs.output[6].message
- $MessageType = "info"
- Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
- #Sleep until the task is done
- While (Test-WAUisRunning) {
- Start-Sleep 3
- }
-
- #Test if there was a list_/winget_error
- if (Test-Path "$WorkingDir\logs\error.txt") {
- $MessageType = "error"
- $Critical = Get-Content "$WorkingDir\logs\error.txt" -Raw
- $Critical = $Critical.Trim()
- $Critical = $Critical.Substring(0, [Math]::Min($Critical.Length, 50))
- $Message = "Critical:`n$Critical..."
- }
- else {
- $MessageType = "success"
- $Message = $NotifLocale.local.outputs.output[9].message
- }
- Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
- }
- catch {
- #Check failed - Just send notification
- $Message = $NotifLocale.local.outputs.output[7].message
- $MessageType = "error"
- Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
- }
+catch {
+ #Check failed - Just send notification
+ $Message = $NotifLocale.local.outputs.output[7].message
+ $MessageType = "error"
+ Start-NotifTask -Message $Message -MessageType $MessageType -Button1Text $Button1Text -Button1Action $OnClickAction -ButtonDismiss -UserRun
}
diff --git a/Sources/Winget-AutoUpdate/Version.txt b/Sources/Winget-AutoUpdate/Version.txt
deleted file mode 100644
index 3d8ac63..0000000
--- a/Sources/Winget-AutoUpdate/Version.txt
+++ /dev/null
@@ -1 +0,0 @@
-1.21.4
\ No newline at end of file
diff --git a/Sources/Winget-AutoUpdate/WAU-Policies.ps1 b/Sources/Winget-AutoUpdate/WAU-Policies.ps1
index 46c1f61..e5c1714 100644
--- a/Sources/Winget-AutoUpdate/WAU-Policies.ps1
+++ b/Sources/Winget-AutoUpdate/WAU-Policies.ps1
@@ -14,7 +14,7 @@ Daily update settings from policies
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
if ($ActivateGPOManagement -eq 1) {
#Add (or update) tag to activate WAU-Policies Management
- New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
+ New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 1 -Force | Out-Null
}
#Get WAU settings
@@ -32,7 +32,7 @@ if ($WAUConfig.WAU_RunGPOManagement -eq 1) {
Add-Content -Path $GPOLogFile -Value "GPO Management Enabled. Policies updated."
}
else {
- New-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null
+ New-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate" -Name WAU_RunGPOManagement -Value 0 -Force | Out-Null
$WAUConfig.WAU_RunGPOManagement = 0
Add-Content -Path $GPOLogFile -Value "GPO Management Disabled. Policies removed."
}
diff --git a/Sources/Winget-AutoUpdate/WAU-Uninstall.ps1 b/Sources/Winget-AutoUpdate/WAU-Uninstall.ps1
deleted file mode 100644
index 5003189..0000000
--- a/Sources/Winget-AutoUpdate/WAU-Uninstall.ps1
+++ /dev/null
@@ -1,86 +0,0 @@
-<#
-.SYNOPSIS
-Uninstall Winget-AutoUpdate
-
-.DESCRIPTION
-Uninstalls Winget-AutoUpdate (DEFAULT: clean old install)
-https://github.com/Romanitho/Winget-AutoUpdate
-
-.PARAMETER NoClean
-Uninstall Winget-AutoUpdate (keep critical files)
-
-.EXAMPLE
-.\WAU-Uninstall.ps1 -NoClean
-
-#>
-
-[CmdletBinding()]
-param(
- [Parameter(Mandatory = $False)] [Switch] $NoClean = $false
-)
-
-Write-Host "`n"
-Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d8b 888 d88P888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d888b 888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888d88888b888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 88888P Y88888 d88P 888 888 888" -ForegroundColor Cyan
-Write-Host "`t 8888P Y8888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta
-Write-Host "`t Winget-AutoUpdate`n" -ForegroundColor Cyan
-Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
-Write-Host "`t________________________________________________________`n`n"
-
-try {
- Write-host "Uninstalling WAU..." -ForegroundColor Yellow
- #Get registry install location
- $InstallLocation = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
-
- #Check if installed location exists and delete
- if (Test-Path ($InstallLocation)) {
-
- if (!$NoClean) {
- Remove-Item "$InstallLocation\*" -Force -Recurse -Exclude "*.log"
- }
- else {
- #Keep critical files
- Get-ChildItem -Path $InstallLocation -Exclude *.txt, mods, logs | Remove-Item -Recurse -Force
- }
- Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
- & reg delete "HKCR\AppUserModelId\Windows.SystemToast.Winget.Notification" /f | Out-Null
- & reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
- if (Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate") {
- & reg delete "HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" /f | Out-Null
- }
-
- if ((Test-Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)")) {
- Remove-Item -Path "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs\Winget-AutoUpdate (WAU)" -Recurse -Force | Out-Null
- }
-
- if ((Test-Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk")) {
- Remove-Item -Path "${env:Public}\Desktop\WAU - Check for updated Apps.lnk" -Force | Out-Null
- }
-
- #Remove Intune Logs if they are existing
- if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log") {
- Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-updates.log" -Force -ErrorAction SilentlyContinue | Out-Null
- }
- if (Test-Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log") {
- Remove-Item -Path "${env:ProgramData}\Microsoft\IntuneManagementExtension\Logs\WAU-install.log" -Force -ErrorAction SilentlyContinue | Out-Null
- }
-
- Write-host "Uninstallation succeeded!" -ForegroundColor Green
- }
- else {
- Write-host "$InstallLocation not found! Uninstallation failed!" -ForegroundColor Red
- }
-}
-catch {
- Write-host "`nUninstallation failed! Run as admin ?" -ForegroundColor Red
-}
-
-Start-sleep 2
diff --git a/Sources/Winget-AutoUpdate/Winget-Install.ps1 b/Sources/Winget-AutoUpdate/Winget-Install.ps1
index 033b925..f9c3d69 100644
--- a/Sources/Winget-AutoUpdate/Winget-Install.ps1
+++ b/Sources/Winget-AutoUpdate/Winget-Install.ps1
@@ -56,7 +56,6 @@ param(
#Include external Functions
. "$PSScriptRoot\functions\Install-Prerequisites.ps1"
-. "$PSScriptRoot\functions\Update-WinGet.ps1"
. "$PSScriptRoot\functions\Update-StoreApps.ps1"
. "$PSScriptRoot\functions\Add-ScopeMachine.ps1"
. "$PSScriptRoot\functions\Get-WingetCmd.ps1"
@@ -311,7 +310,7 @@ $CurrentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Pri
$Script:IsElevated = $CurrentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
#Get WAU Installed location
-$WAURegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\"
+$WAURegKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\"
$Script:WAUInstallLocation = Get-ItemProperty $WAURegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty InstallLocation
#LogPath initialization
@@ -339,20 +338,6 @@ else {
$Script:LogFile = "$LogPath\install_$env:UserName.log"
}
-#Header (not logged)
-Write-Host "`n "
-Write-Host "`t 888 888 d8888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 o 888 d88888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d8b 888 d88P888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888 d888b 888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888d88888b888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 88888P Y88888 d88P 888 888 888" -ForegroundColor Cyan
-Write-Host "`t 8888P Y8888 d88P 888 888 888" -ForegroundColor Magenta
-Write-Host "`t 888P Y888 d88P 888 Y8888888P`n" -ForegroundColor Magenta
-Write-Host "`t Winget-AutoUpdate`n" -ForegroundColor Cyan
-Write-Host "`t https://github.com/Romanitho/Winget-AutoUpdate`n" -ForegroundColor Magenta
-Write-Host "`t________________________________________________________`n`n"
-
#Log Header
if ($Uninstall) {
Write-ToLog -LogMsg "NEW UNINSTALL REQUEST" -LogColor "Magenta" -IsHeader
@@ -361,22 +346,23 @@ else {
Write-ToLog -LogMsg "NEW INSTALL REQUEST" -LogColor "Magenta" -IsHeader
}
-#Get Winget command
-$Script:Winget = Get-WingetCmd
-
if ($IsElevated -eq $True) {
Write-ToLog "Running with admin rights.`n"
+
#Check/install prerequisites
Install-Prerequisites
- #Install/Update Winget
- $null = Update-Winget
+
#Reload Winget command
$Script:Winget = Get-WingetCmd
+
#Run Scope Machine function
Add-ScopeMachine
}
else {
Write-ToLog "Running without admin rights.`n"
+
+ #Get Winget command
+ $Script:Winget = Get-WingetCmd
}
if ($Winget) {
diff --git a/Sources/Winget-AutoUpdate/Winget-Notify.ps1 b/Sources/Winget-AutoUpdate/Winget-Notify.ps1
index de22ef7..f34a434 100644
--- a/Sources/Winget-AutoUpdate/Winget-Notify.ps1
+++ b/Sources/Winget-AutoUpdate/Winget-Notify.ps1
@@ -1,7 +1,7 @@
#Send Notify Script
#get xml notif config
-$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate\" -Name InstallLocation
+$WAUinstalledPath = Get-ItemPropertyValue -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate\" -Name InstallLocation
[xml]$NotifConf = Get-Content "$WAUinstalledPath\config\notif.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
if (!($NotifConf)) {
break
@@ -16,7 +16,7 @@ $ToastXml = [Windows.Data.Xml.Dom.XmlDocument]::New()
$ToastXml.LoadXml($NotifConf.OuterXml)
#Specify Launcher App ID
-$LauncherID = "Windows.SystemToast.Winget.Notification"
+$LauncherID = "Windows.SystemToast.WAU.Notification"
#Prepare and Create Toast
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXML)
diff --git a/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1
index 8208061..7b3a583 100644
--- a/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1
+++ b/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1
@@ -50,7 +50,8 @@ if ($IsSystem) {
$null = (New-Item "$WorkingDir\logs\symlink.txt" -Value $symLink -Force)
}
#Rerun WAU in system context with ServiceUI
- & $WorkingDir\ServiceUI.exe -process:explorer.exe $env:windir\System32\wscript.exe \`"$WorkingDir\Invisible.vbs\`" \`"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \`"\`"$WorkingDir\winget-upgrade.ps1\`"\`"\`"
+ Start-Process "ServiceUI.exe" -ArgumentList "-process:explorer.exe $env:windir\System32\conhost.exe --headless powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-upgrade.ps1" -WorkingDirectory $WorkingDir
+ Wait-Process "ServiceUI" -ErrorAction SilentlyContinue
Exit 0
}
else {
@@ -126,19 +127,23 @@ Write-ToLog "Notification Level: $($WAUConfig.WAU_NotificationLevel). Notificati
#Check network connectivity
if (Test-Network) {
+
+ #Check prerequisites
+ if ($IsSystem) {
+ Install-Prerequisites
+ }
+
#Check if Winget is installed and get Winget cmd
$Script:Winget = Get-WingetCmd
if ($Winget) {
- #Log Winget installed version
- $WingetVer = & $Winget --version
- Write-ToLog "Winget Version: $WingetVer"
-
- #Get Current Version
- $WAUCurrentVersion = $WAUConfig.DisplayVersion
- Write-ToLog "WAU current version: $WAUCurrentVersion"
if ($IsSystem) {
+
+ #Get Current Version
+ $WAUCurrentVersion = $WAUConfig.ProductVersion
+ Write-ToLog "WAU current version: $WAUCurrentVersion"
+
#Check if WAU update feature is enabled or not if run as System
$WAUDisableAutoUpdate = $WAUConfig.WAU_DisableAutoUpdate
#If yes then check WAU update if run as System
@@ -150,7 +155,7 @@ if (Test-Network) {
#Get Available Version
$Script:WAUAvailableVersion = Get-WAUAvailableVersion
#Compare
- if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion) {
+ if ([version]$WAUAvailableVersion.replace("-n", "") -gt [version]$WAUCurrentVersion.replace("-n", "")) {
#If new version is available, update it
Write-ToLog "WAU Available version: $WAUAvailableVersion" "Yellow"
Update-WAU
@@ -375,40 +380,23 @@ if (Test-Network) {
}
#Check if user context is activated during system run
- if ($IsSystem) {
+ if ($IsSystem -and ($WAUConfig.WAU_UserContext -eq 1)) {
- #Run WAU in user context if feature is activated
- if ($WAUConfig.WAU_UserContext -eq 1) {
+ $UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
- #Create User context task if not existing
- $UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
- if (!$UserContextTask) {
- #Create the scheduled task in User context
- $taskAction = New-ScheduledTaskAction -Execute "wscript.exe" -Argument "`"$($WAUConfig.InstallLocation)\Invisible.vbs`" `"powershell.exe -NoProfile -ExecutionPolicy Bypass -File `"`"`"$($WAUConfig.InstallLocation)\winget-upgrade.ps1`"`""
- $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
- Write-ToLog "-> User Context task created."
+ $explorerprocesses = @(Get-CimInstance -Query "SELECT * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
+ If ($explorerprocesses.Count -eq 0) {
+ Write-ToLog "No explorer process found / Nobody interactively logged on..."
+ }
+ Else {
+ #Get Winget system apps to escape them before running user context
+ Write-ToLog "User logged on, get a list of installed Winget apps in System context..."
+ Get-WingetSystemApps
- #Load it
- $UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -ErrorAction SilentlyContinue
- }
-
- $explorerprocesses = @(Get-CimInstance -Query "SELECT * FROM Win32_Process WHERE Name='explorer.exe'" -ErrorAction SilentlyContinue)
- If ($explorerprocesses.Count -eq 0) {
- Write-ToLog "No explorer process found / Nobody interactively logged on..."
- }
- Else {
- #Get Winget system apps to escape them before running user context
- Write-ToLog "User logged on, get a list of installed Winget apps in System context..."
- Get-WingetSystemApps
-
- #Run user context scheduled task
- Write-ToLog "Starting WAU in User context..."
- $null = $UserContextTask | Start-ScheduledTask -ErrorAction SilentlyContinue
- Exit 0
- }
+ #Run user context scheduled task
+ Write-ToLog "Starting WAU in User context..."
+ $null = $UserContextTask | Start-ScheduledTask -ErrorAction SilentlyContinue
+ Exit 0
}
}
}
diff --git a/Sources/Winget-AutoUpdate/config/WAU-MSI_Actions.ps1 b/Sources/Winget-AutoUpdate/config/WAU-MSI_Actions.ps1
new file mode 100644
index 0000000..997ad12
--- /dev/null
+++ b/Sources/Winget-AutoUpdate/config/WAU-MSI_Actions.ps1
@@ -0,0 +1,173 @@
+[CmdletBinding()]
+param(
+ [Parameter(Mandatory = $false)] [string] $AppListPath,
+ [Parameter(Mandatory = $false)] [string] $InstallPath,
+ [Parameter(Mandatory = $false)] [string] $Upgrade,
+ [Parameter(Mandatory = $False)] [Switch] $Uninstall = $false
+)
+
+#For troubleshooting
+Write-Output "AppListPath: $AppListPath"
+Write-Output "InstallPath: $InstallPath"
+Write-Output "Upgrade: $Upgrade"
+Write-Output "Uninstall: $Uninstall"
+
+
+<# FUNCTIONS #>
+
+function Install-WingetAutoUpdate {
+
+ Write-Host "### Post install actions ###"
+
+ try {
+
+ # Clean potential old v1 install
+ $OldConfRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
+ $OldWAUConfig = Get-ItemProperty $OldConfRegPath -ErrorAction SilentlyContinue
+ if ($OldWAUConfig.InstallLocation) {
+ Write-Host "-> Cleanning old v1 WAU version ($($OldWAUConfig.DisplayVersion))"
+ Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -WindowStyle Hidden -File ""$($OldWAUConfig.InstallLocation)\WAU-Uninstall.ps1""" -Wait
+ }
+
+ #Get WAU config
+ $WAUconfig = Get-ItemProperty "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
+ Write-Output "-> WAU Config:"
+ Write-Output $WAUconfig
+
+ # Settings for the scheduled task for Updates (System)
+ Write-Host "-> Installing WAU scheduled tasks"
+ $taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($InstallPath)winget-upgrade.ps1`""
+ $taskTriggers = @()
+ if ($WAUconfig.WAU_UpdatesAtLogon -eq 1) {
+ $tasktriggers += New-ScheduledTaskTrigger -AtLogOn
+ }
+ if ($WAUconfig.WAU_UpdatesInterval -eq "Daily") {
+ $tasktriggers += New-ScheduledTaskTrigger -Daily -At $WAUconfig.WAU_UpdatesAtTime
+ }
+ elseif ($WAUconfig.WAU_UpdatesInterval -eq "BiDaily") {
+ $tasktriggers += New-ScheduledTaskTrigger -Daily -At $WAUconfig.WAU_UpdatesAtTime -DaysInterval 2
+ }
+ elseif ($WAUconfig.WAU_UpdatesInterval -eq "Weekly") {
+ $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $WAUconfig.WAU_UpdatesAtTime -DaysOfWeek 2
+ }
+ elseif ($WAUconfig.WAU_UpdatesInterval -eq "BiWeekly") {
+ $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $WAUconfig.WAU_UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 2
+ }
+ elseif ($WAUconfig.WAU_UpdatesInterval -eq "Monthly") {
+ $tasktriggers += New-ScheduledTaskTrigger -Weekly -At $WAUconfig.WAU_UpdatesAtTime -DaysOfWeek 2 -WeeksInterval 4
+ }
+ $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
+ $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
+ # Set up the task, and register it
+ if ($taskTriggers) {
+ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTriggers
+ }
+ else {
+ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
+ }
+ Register-ScheduledTask -TaskName 'Winget-AutoUpdate' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
+
+ # Settings for the scheduled task in User context
+ $taskAction = New-ScheduledTaskAction -Execute "conhost.exe" -Argument "--headless powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-upgrade.ps1" -WorkingDirectory $InstallPath
+ $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
+ $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 03:00:00
+ # Set up the task for user apps
+ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
+ Register-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
+
+ # Settings for the scheduled task for Notifications
+ $taskAction = New-ScheduledTaskAction -Execute "conhost.exe" -Argument "--headless powershell.exe -NoProfile -ExecutionPolicy Bypass -File winget-notify.ps1" -WorkingDirectory $InstallPath
+ $taskUserPrincipal = New-ScheduledTaskPrincipal -GroupId S-1-5-11
+ $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
+ # Set up the task, and register it
+ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings
+ Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Notify' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
+
+ # Settings for the GPO scheduled task
+ $taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($InstallPath)WAU-Policies.ps1`""
+ $tasktrigger = New-ScheduledTaskTrigger -Daily -At 6am
+ $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
+ $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
+ # Set up the task, and register it
+ $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger
+ Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Policies' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
+
+ #Set task readable/runnable for all users
+ $scheduler = New-Object -ComObject "Schedule.Service"
+ $scheduler.Connect()
+ $task = $scheduler.GetFolder("WAU").GetTask("Winget-AutoUpdate")
+ $sec = $task.GetSecurityDescriptor(0xF)
+ $sec = $sec + '(A;;GRGX;;;AU)'
+ $task.SetSecurityDescriptor($sec, 0)
+
+ #Copy App list to install folder (exept on self update)
+ if ($AppListPath -and ($AppListPath -notlike "$InstallPath*")) {
+ Write-Output "-> Copying $AppListPath to $InstallPath"
+ Copy-Item -Path $AppListPath -Destination $InstallPath
+ }
+
+ #Add 1 to counter file
+ try {
+ Invoke-RestMethod -Uri "https://github.com/Romanitho/WAU-MSI/releases/download/v$($WAUconfig.ProductVersion)/WAU_InstallCounter" | Out-Null
+ Write-Host "-> Reported installation."
+ }
+ catch {
+ Write-Host "-> Not able to report installation."
+ }
+
+ Write-Host "### WAU MSI Post actions succeeded! ###"
+
+ }
+ catch {
+ Write-Host "### WAU Installation failed! Error $_. ###"
+ return $False
+ }
+}
+
+function Uninstall-WingetAutoUpdate {
+
+ Write-Host "### Uninstalling WAU started! ###"
+
+ Write-Host "-> Removing scheduled tasks."
+ Get-ScheduledTask -TaskName "Winget-AutoUpdate" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
+ Get-ScheduledTask -TaskName "Winget-AutoUpdate-Notify" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
+ Get-ScheduledTask -TaskName "Winget-AutoUpdate-UserContext" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
+ Get-ScheduledTask -TaskName "Winget-AutoUpdate-Policies" -ErrorAction SilentlyContinue | Unregister-ScheduledTask -Confirm:$False
+
+ #If upgrade, keep app list. Else, remove.
+ if ($Upgrade -like "#{*}") {
+ Write-Output "-> Upgrade detected. Keeping *.txt app lists"
+ }
+ else {
+ $AppLists = Get-Item (Join-Path "$InstallPath" "*_apps.txt")
+ if ($AppLists) {
+ Write-Output "-> Removing items: $AppLists"
+ Remove-Item $AppLists -Force
+ }
+ }
+
+ $ConfFolder = Get-Item (Join-Path "$InstallPath" "config") -ErrorAction SilentlyContinue
+ if ($ConfFolder) {
+ Write-Output "-> Removing item: $ConfFolder"
+ Remove-Item $ConfFolder -Force -Recurse
+ }
+
+ Write-Host "### Uninstallation done! ###"
+ Start-sleep 1
+}
+
+
+<# MAIN #>
+
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+$Script:ProgressPreference = 'SilentlyContinue'
+
+
+# Uninstall
+if ($Uninstall) {
+ Uninstall-WingetAutoUpdate
+}
+# Install
+else {
+ Install-WingetAutoUpdate
+}
diff --git a/Sources/Winget-AutoUpdate/functions/Get-WAUConfig.ps1 b/Sources/Winget-AutoUpdate/functions/Get-WAUConfig.ps1
index 0772a82..a202d55 100644
--- a/Sources/Winget-AutoUpdate/functions/Get-WAUConfig.ps1
+++ b/Sources/Winget-AutoUpdate/functions/Get-WAUConfig.ps1
@@ -3,7 +3,8 @@
Function Get-WAUConfig {
#Get WAU Configurations from install config
- $WAUConfig = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -ErrorAction SilentlyContinue
+ $WAUConfig_64_86 = Get-ItemProperty -Path "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate*", "HKLM:\SOFTWARE\WOW6432Node\Romanitho\Winget-AutoUpdate*" -ErrorAction SilentlyContinue | Sort-Object { $_.ProductVersion } -Descending
+ $WAUConfig = $WAUConfig_64_86[0]
#Check if GPO Management is enabled
$ActivateGPOManagement = Get-ItemPropertyValue "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "WAU_ActivateGPOManagement" -ErrorAction SilentlyContinue
diff --git a/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1 b/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1
index 3be9bc1..edc70b7 100644
--- a/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1
+++ b/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1
@@ -29,7 +29,7 @@ function Install-Prerequisites {
Write-ToLog "-> Downloading $SourceURL..."
Invoke-WebRequest $SourceURL -UseBasicParsing -OutFile $Installer
Write-ToLog "-> Installing VC_redist.$OSArch.exe..."
- Start-Process -FilePath $Installer -Args "/passive /norestart" -Wait
+ Start-Process -FilePath $Installer -Args "/quiet /norestart" -Wait
Start-Sleep 3
Write-ToLog "-> MS Visual C++ 2015-2022 installed successfully." "Green"
}
@@ -86,12 +86,70 @@ function Install-Prerequisites {
}
}
- Write-ToLog "Prerequisites checked. OK`n" "Green"
+ #Check if Winget is installed (and up to date)
+ try {
+ #Get latest WinGet info
+ $WinGeturl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
+ $WinGetAvailableVersion = ((Invoke-WebRequest $WinGeturl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
+ }
+ catch {
+ #if fail set version to the latest version as of 2024-04-29
+ $WinGetAvailableVersion = "1.7.11132"
+ }
+ try {
+ #Get Admin Context Winget Location
+ $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
+ #If multiple versions, pick most recent one
+ $WingetCmd = $WingetInfo[-1].FileName
+ #Get current Winget Version
+ $WingetInstalledVersion = (& $WingetCmd -v).Replace("v", "").trim()
+ }
+ catch {
+ Write-ToLog "WinGet is not installed" "Red"
+ }
+ #Check if the current available WinGet is newer than the installed
+ if ($WinGetAvailableVersion -gt $WinGetInstalledVersion) {
+ #Install WinGet MSIXBundle in SYSTEM context
+ try {
+ #Download WinGet MSIXBundle
+ Write-ToLog "-> Downloading WinGet MSIXBundle for App Installer..."
+ $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v$WinGetAvailableVersion/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
+ $WingetInstaller = "$env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
+ Invoke-RestMethod -Uri $WinGetURL -OutFile $WingetInstaller
+
+ #Install
+ Write-ToLog "-> Installing WinGet MSIXBundle for App Installer..."
+ Add-AppxProvisionedPackage -Online -PackagePath $WingetInstaller -SkipLicense | Out-Null
+ Write-ToLog "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully!" "green"
+
+ #Reset WinGet Sources
+ $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
+ #If multiple versions, pick most recent one
+ $WingetCmd = $WingetInfo[-1].FileName
+ & $WingetCmd source reset --force
+ Write-ToLog "-> WinGet sources reset." "green"
+ $return = "success"
+ }
+ catch {
+ Write-ToLog "-> Failed to install WinGet MSIXBundle for App Installer..." "red"
+ #Force Store Apps to update
+ Update-StoreApps
+ $return = "fail"
+ }
+
+ #Remove WinGet MSIXBundle
+ Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue
+ }
+ else {
+ Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion" "Green"
+ }
+
+ Write-ToLog "Prerequisites checked. OK" "Green"
}
catch {
- Write-ToLog "Prerequisites checked failed`n" "Red"
+ Write-ToLog "Prerequisites checked failed" "Red"
}
diff --git a/Sources/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1 b/Sources/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1
deleted file mode 100644
index 00eb446..0000000
--- a/Sources/Winget-AutoUpdate/functions/Invoke-PostUpdateActions.ps1
+++ /dev/null
@@ -1,168 +0,0 @@
-#Function to make actions after WAU update
-
-function Invoke-PostUpdateActions {
-
- #log
- Write-ToLog "Running Post Update actions:" "yellow"
-
- #Update Winget if not up to date
- $null = Update-WinGet
-
- #Create WAU Regkey if not present
- $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
- if (!(test-path $regPath)) {
- New-Item $regPath -Force
- New-ItemProperty $regPath -Name DisplayName -Value "Winget-AutoUpdate (WAU)" -Force
- New-ItemProperty $regPath -Name DisplayIcon -Value "C:\Windows\System32\shell32.dll,-16739" -Force
- New-ItemProperty $regPath -Name NoModify -Value 1 -Force
- New-ItemProperty $regPath -Name NoRepair -Value 1 -Force
- New-ItemProperty $regPath -Name Publisher -Value "Romanitho" -Force
- New-ItemProperty $regPath -Name URLInfoAbout -Value "https://github.com/Romanitho/Winget-AutoUpdate" -Force
- New-ItemProperty $regPath -Name InstallLocation -Value $WorkingDir -Force
- New-ItemProperty $regPath -Name UninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force
- New-ItemProperty $regPath -Name QuietUninstallString -Value "powershell.exe -noprofile -executionpolicy bypass -file `"$WorkingDir\WAU-Uninstall.ps1`"" -Force
- New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 0 -PropertyType DWord -Force
-
- #log
- Write-ToLog "-> $regPath created." "green"
- }
- #Fix Notif where WAU_NotificationLevel is not set
- $regNotif = Get-ItemProperty $regPath -Name WAU_NotificationLevel -ErrorAction SilentlyContinue
- if (!$regNotif) {
- New-ItemProperty $regPath -Name WAU_NotificationLevel -Value Full -Force
-
- #log
- Write-ToLog "-> Notification level setting was missing. Fixed with 'Full' option."
- }
-
- #Set WAU_MaxLogFiles/WAU_MaxLogSize if not set
- $MaxLogFiles = Get-ItemProperty $regPath -Name WAU_MaxLogFiles -ErrorAction SilentlyContinue
- if (!$MaxLogFiles) {
- New-ItemProperty $regPath -Name WAU_MaxLogFiles -Value 3 -PropertyType DWord -Force | Out-Null
- New-ItemProperty $regPath -Name WAU_MaxLogSize -Value 1048576 -PropertyType DWord -Force | Out-Null
-
- #log
- Write-ToLog "-> MaxLogFiles/MaxLogSize setting was missing. Fixed with 3/1048576 (in bytes, default is 1048576 = 1 MB)."
- }
-
- #Security check
- Write-ToLog "-> Checking Mods Directory:" "yellow"
- $Protected = Invoke-DirProtect "$($WAUConfig.InstallLocation)\mods"
- if ($Protected -eq $True) {
- Write-ToLog "-> The mods directory is secured!" "green"
- }
- else {
- Write-ToLog "-> Error: The mods directory couldn't be verified as secured!" "red"
- }
- Write-ToLog "-> Checking Functions Directory:" "yellow"
- $Protected = Invoke-DirProtect "$($WAUConfig.InstallLocation)\Functions"
- if ($Protected -eq $True) {
- Write-ToLog "-> The Functions directory is secured!" "green"
- }
- else {
- Write-ToLog "-> Error: The Functions directory couldn't be verified as secured!" "red"
- }
-
- #Convert about.xml if exists (old WAU versions) to reg
- $WAUAboutPath = "$WorkingDir\config\about.xml"
- if (test-path $WAUAboutPath) {
- [xml]$About = Get-Content $WAUAboutPath -Encoding UTF8 -ErrorAction SilentlyContinue
- New-ItemProperty $regPath -Name DisplayVersion -Value $About.app.version -Force
-
- #Remove file once converted
- Remove-Item $WAUAboutPath -Force -Confirm:$false
-
- #log
- Write-ToLog "-> $WAUAboutPath converted." "green"
- }
-
- #Convert config.xml if exists (previous WAU versions) to reg
- $WAUConfigPath = "$WorkingDir\config\config.xml"
- if (test-path $WAUConfigPath) {
- [xml]$Config = Get-Content $WAUConfigPath -Encoding UTF8 -ErrorAction SilentlyContinue
- if ($Config.app.WAUautoupdate -eq "False") { New-ItemProperty $regPath -Name WAU_DisableAutoUpdate -Value 1 -Force }
- if ($Config.app.NotificationLevel) { New-ItemProperty $regPath -Name WAU_NotificationLevel -Value $Config.app.NotificationLevel -Force }
- if ($Config.app.UseWAUWhiteList -eq "True") { New-ItemProperty $regPath -Name WAU_UseWhiteList -Value 1 -PropertyType DWord -Force }
- if ($Config.app.WAUprerelease -eq "True") { New-ItemProperty $regPath -Name WAU_UpdatePrerelease -Value 1 -PropertyType DWord -Force }
-
- #Remove file once converted
- Remove-Item $WAUConfigPath -Force -Confirm:$false
-
- #log
- Write-ToLog "-> $WAUConfigPath converted." "green"
- }
-
- #Remove old functions / files
- $FileNames = @(
- "$WorkingDir\functions\Start-Init.ps1",
- "$WorkingDir\functions\Get-Policies.ps1",
- "$WorkingDir\functions\Get-WAUCurrentVersion.ps1",
- "$WorkingDir\functions\Get-WAUUpdateStatus.ps1",
- "$WorkingDir\functions\Write-Log.ps1",
- "$WorkingDir\functions\Get-WinGetAvailableVersion.ps1",
- "$WorkingDir\functions\Invoke-ModsProtect.ps1",
- "$WorkingDir\functions\Write-CMTraceLog.ps1",
- "$WorkingDir\Version.txt",
- "$WorkingDir\winget_system_apps.txt"
- )
- foreach ($FileName in $FileNames) {
- if (Test-Path $FileName) {
- Remove-Item $FileName -Force -Confirm:$false
-
- #log
- Write-ToLog "-> $FileName removed." "green"
- }
- }
-
- #Remove old registry key
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMajor" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "VersionMinor" -ErrorAction SilentlyContinue
- Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Romanitho\Winget-AutoUpdate" -Name "DisplayVersion" -ErrorAction SilentlyContinue
-
- #Activate WAU in user context if previously configured (as "Winget-AutoUpdate-UserContext" at root)
- $UserContextTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-UserContext' -TaskPath '\' -ErrorAction SilentlyContinue
- if ($UserContextTask) {
- #Remove Winget-AutoUpdate-UserContext at root.
- $null = $UserContextTask | Unregister-ScheduledTask -Confirm:$False
-
- #Set it in registry as activated.
- New-ItemProperty $regPath -Name WAU_UserContext -Value 1 -PropertyType DWord -Force | Out-Null
- Write-ToLog "-> Old User Context task deleted and set to 'enabled' in registry."
- }
-
- #Set GPO scheduled task if not existing
- $GPOTask = Get-ScheduledTask -TaskName 'Winget-AutoUpdate-Policies' -ErrorAction SilentlyContinue
- if (!$GPOTask) {
- $taskAction = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$($WorkingDir)\WAU-Policies.ps1`""
- $tasktrigger = New-ScheduledTaskTrigger -Daily -At 6am
- $taskUserPrincipal = New-ScheduledTaskPrincipal -UserId S-1-5-18 -RunLevel Highest
- $taskSettings = New-ScheduledTaskSettingsSet -Compatibility Win8 -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit 00:05:00
- # Set up the task, and register it
- $task = New-ScheduledTask -Action $taskAction -Principal $taskUserPrincipal -Settings $taskSettings -Trigger $taskTrigger
- Register-ScheduledTask -TaskName 'Winget-AutoUpdate-Policies' -TaskPath 'WAU' -InputObject $task -Force | Out-Null
- Write-ToLog "-> Policies task created."
- }
-
-
- ### End of post update actions ###
-
- #Reset WAU_UpdatePostActions Value
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 0 -Force | Out-Null
-
- #Get updated WAU Config
- $Script:WAUConfig = Get-WAUConfig
-
- #Add 1 to counter file
- try {
- Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUConfig.DisplayVersion)/WAU_InstallCounter" | Out-Null
- }
- catch {
- Write-ToLog "-> Not able to report installation." "Yellow"
- }
-
- #log
- Write-ToLog "Post Update actions finished" "green"
-
-}
diff --git a/Sources/Winget-AutoUpdate/functions/Start-NotifTask.ps1 b/Sources/Winget-AutoUpdate/functions/Start-NotifTask.ps1
index 4f5ec01..02c9d04 100644
--- a/Sources/Winget-AutoUpdate/functions/Start-NotifTask.ps1
+++ b/Sources/Winget-AutoUpdate/functions/Start-NotifTask.ps1
@@ -155,7 +155,7 @@ function Start-NotifTask {
$ToastXml.LoadXml($ToastTemplate.OuterXml)
#Specify Launcher App ID
- $LauncherID = "Windows.SystemToast.Winget.Notification"
+ $LauncherID = "Windows.SystemToast.WAU.Notification"
#Prepare and Create Toast
$ToastMessage = [Windows.UI.Notifications.ToastNotification]::New($ToastXml)
diff --git a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1
index 2bc0d11..8fa2cc2 100644
--- a/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1
+++ b/Sources/Winget-AutoUpdate/functions/Update-WAU.ps1
@@ -1,5 +1,3 @@
-#Function to update WAU
-
function Update-WAU {
$OnClickAction = "https://github.com/Romanitho/Winget-AutoUpdate/releases"
@@ -13,113 +11,34 @@ function Update-WAU {
#Run WAU update
try {
- #Try WAU.zip (v1)
+ #Download the msi
+ Write-ToLog "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan"
+ $MsiFile = "$env:temp\WAU.msi"
+ Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.msi" -OutFile $MsiFile
- #Force to create a zip file
- $ZipFile = "$WorkingDir\WAU_update.zip"
- New-Item $ZipFile -ItemType File -Force | Out-Null
-
- #Download the zip
- Write-ToLog "Downloading the GitHub Repository Zip version $WAUAvailableVersion" "Cyan"
- Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.zip" -OutFile $ZipFile
-
- #Extract Zip File
- Write-ToLog "Unzipping the WAU Update package" "Cyan"
- $location = "$WorkingDir\WAU_update"
- Expand-Archive -Path $ZipFile -DestinationPath $location -Force
- Get-ChildItem -Path $location -Recurse | Unblock-File
-
- #Update scritps
+ #Update WAU
Write-ToLog "Updating WAU..." "Yellow"
- $TempPath = (Resolve-Path "$location\Winget-AutoUpdate\")[0].Path
- $ServiceUI = Test-Path "$WorkingDir\ServiceUI.exe"
- if ($TempPath -and $ServiceUI) {
- #Do not copy ServiceUI if already existing, causing error if in use.
- Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude ("icons", "ServiceUI.exe") -Recurse -Force
- }
- elseif ($TempPath) {
- Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force
- }
-
- #Remove update zip file and update temp folder
- Write-ToLog "Done. Cleaning temp files..." "Cyan"
- Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue
- Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue
-
- #Set new version to registry
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "DisplayVersion" -Value $WAUAvailableVersion -Force | Out-Null
-
- #Set Post Update actions to 1
- New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate" -Name "WAU_PostUpdateActions" -Value 1 -Force | Out-Null
+ Start-Process msiexec.exe -ArgumentList "/i $MsiFile /qn /L*v ""$WorkingDir\logs\WAU-Installer.log"" RUN_WAU=YES" -Wait
#Send success Notif
- Write-ToLog "WAU Update completed." "Green"
+ Write-ToLog "WAU Update completed. Rerunning WAU..." "Green"
$Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
$Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion
$MessageType = "success"
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
- #Rerun with newer version
- Write-ToLog "Re-run WAU"
- Start-Process powershell -ArgumentList "-NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -Command `"$WorkingDir\winget-upgrade.ps1`""
-
- exit
-
+ exit 0
}
catch {
- #Try WAU.msi (v2)
- try {
- #Download the msi
- Write-ToLog "Downloading the GitHub Repository MSI version $WAUAvailableVersion" "Cyan"
- $MsiFile = "$env:temp\WAU.msi"
- Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/releases/download/v$($WAUAvailableVersion)/WAU.msi" -OutFile $MsiFile
+ #Send Error Notif
+ $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate"
+ $Message = $NotifLocale.local.outputs.output[4].message
+ $MessageType = "error"
+ Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
+ Write-ToLog "WAU Update failed" "Red"
- #Migrate registry to save current WAU settings
- Write-ToLog "Saving current config before updating with MSI"
- $sourcePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
- $destinationPath = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
- #Create the destination key if it doesn't exist
- if (-not (Test-Path -Path $destinationPath)) {
- New-Item -Path $destinationPath -ItemType Directory -Force
- Write-ToLog "New registry key created."
- }
- #Retrieve the properties of the source key
- $properties = Get-ItemProperty -Path $sourcePath
- foreach ($property in $properties.PSObject.Properties) {
- #Check if the value name starts with "WAU_"
- if ($property.Name -like "WAU_*") {
- #Copy the value to the destination key
- Set-ItemProperty -Path $destinationPath -Name $property.Name -Value $property.Value
- Write-ToLog "$($property.Name) saved."
- }
- }
-
- #Update WAU and run
- Write-ToLog "Updating WAU..." "Yellow"
- Start-Process msiexec.exe -ArgumentList "/i $MsiFile /qn /L*v ""$WorkingDir\logs\WAU-Installer.log"" RUN_WAU=YES" -Wait
-
- #Send success Notif
- Write-ToLog "WAU Update completed. Rerunning WAU..." "Green"
- $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
- $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion
- $MessageType = "success"
- Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
-
- Exit 0
- }
-
- catch {
-
- #Send Error Notif
- $Title = $NotifLocale.local.outputs.output[4].title -f "Winget-AutoUpdate"
- $Message = $NotifLocale.local.outputs.output[4].message
- $MessageType = "error"
- Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Button1Action $OnClickAction -Button1Text $Button1Text
- Write-ToLog "WAU Update failed" "Red"
-
- }
}
-}
+}
\ No newline at end of file
diff --git a/Sources/Winget-AutoUpdate/functions/Update-WinGet.ps1 b/Sources/Winget-AutoUpdate/functions/Update-WinGet.ps1
deleted file mode 100644
index 88bf74a..0000000
--- a/Sources/Winget-AutoUpdate/functions/Update-WinGet.ps1
+++ /dev/null
@@ -1,73 +0,0 @@
-#Function to download and update WinGet
-
-Function Update-WinGet {
-
- Write-ToLog "Checking if WinGet is installed/up to date." "Yellow"
-
- #Get latest WinGet info
- $WinGeturl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
-
- try {
- #Return latest version
- $WinGetAvailableVersion = ((Invoke-WebRequest $WinGeturl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v", "")
- }
- catch {
- #if fail set version to the latest version as of 2024-04-29
- $WinGetAvailableVersion = "1.7.11132"
- }
-
- try {
- #Get Admin Context Winget Location
- $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
- #If multiple versions, pick most recent one
- $WingetCmd = $WingetInfo[-1].FileName
- #Get current Winget Version
- $WingetInstalledVersion = [regex]::match((& $WingetCmd -v), '((\d+\.)(\d+\.)(\d+))').Groups[1].Value
- }
- catch {
- Write-ToLog "-> WinGet is not installed" "Red"
- }
-
- #Check if the current available WinGet is newer than the installed
- if ($WinGetAvailableVersion -gt $WinGetInstalledVersion) {
-
- #Install WinGet MSIXBundle in SYSTEM context
- try {
- #Download WinGet MSIXBundle
- Write-ToLog "-> Downloading WinGet MSIXBundle for App Installer..."
- $WinGetURL = "https://github.com/microsoft/winget-cli/releases/download/v$WinGetAvailableVersion/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
- $WingetInstaller = "$env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
- Invoke-RestMethod -Uri $WinGetURL -OutFile $WingetInstaller
-
- #Install
- Write-ToLog "-> Installing WinGet MSIXBundle for App Installer..."
- Add-AppxProvisionedPackage -Online -PackagePath $WingetInstaller -SkipLicense | Out-Null
- Write-ToLog "-> WinGet MSIXBundle (v$WinGetAvailableVersion) for App Installer installed successfully!" "green"
-
- #Reset WinGet Sources
- $WingetInfo = (Get-Item "$env:ProgramFiles\WindowsApps\Microsoft.DesktopAppInstaller_*_8wekyb3d8bbwe\winget.exe").VersionInfo | Sort-Object -Property FileVersionRaw
- #If multiple versions, pick most recent one
- $WingetCmd = $WingetInfo[-1].FileName
- & $WingetCmd source reset --force
- Write-ToLog "-> WinGet sources reset.`n" "green"
- $return = "success"
-
- }
- catch {
- Write-ToLog "-> Failed to install WinGet MSIXBundle for App Installer...`n" "red"
- #Force Store Apps to update
- Update-StoreApps
- $return = "fail"
- }
-
- #Remove WinGet MSIXBundle
- Remove-Item -Path $WingetInstaller -Force -ErrorAction SilentlyContinue
-
- #Return status
- return $return
- }
- else {
- Write-ToLog "-> WinGet is up to date: v$WinGetInstalledVersion`n" "Green"
- return "current"
- }
-}
diff --git a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1 b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1
index 5880847..b7fa5f2 100644
--- a/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1
+++ b/Sources/Winget-AutoUpdate/mods/_AppID-template.ps1
@@ -35,7 +35,7 @@ $AllVersions = $False
$Lnk = @("")
#Registry _value_ (DWord/String) to add in existing registry Key (Key created if not existing). Example:
-#$AddKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
+#$AddKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
#$AddValue = "WAU_BypassListForUsers"
#$AddTypeData = "1"
#$AddType = "DWord"
@@ -46,7 +46,7 @@ $AddType = ""
#Registry _value_ to delete in existing registry Key.
#Value can be omitted for deleting entire Key!. Example:
-#$DelKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Winget-AutoUpdate"
+#$DelKey = "HKLM:\SOFTWARE\Romanitho\Winget-AutoUpdate"
#$DelValue = "WAU_BypassListForUsers"
$DelKey = ""
$DelValue = ""
diff --git a/Sources/Wix/build.wxs b/Sources/Wix/build.wxs
new file mode 100644
index 0000000..37450ee
--- /dev/null
+++ b/Sources/Wix/build.wxs
@@ -0,0 +1,369 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Sources/Wix/files/banner.bmp b/Sources/Wix/files/banner.bmp
new file mode 100644
index 0000000..04921ac
Binary files /dev/null and b/Sources/Wix/files/banner.bmp differ
diff --git a/Sources/Wix/files/dialog.bmp b/Sources/Wix/files/dialog.bmp
new file mode 100644
index 0000000..92c6bc0
Binary files /dev/null and b/Sources/Wix/files/dialog.bmp differ
diff --git a/Sources/Wix/files/icon.ico b/Sources/Wix/files/icon.ico
new file mode 100644
index 0000000..6cd5a13
Binary files /dev/null and b/Sources/Wix/files/icon.ico differ