forked from iNavFlight/inav-configurator
-
Notifications
You must be signed in to change notification settings - Fork 6
/
post_install_cleanup.ps1
executable file
·31 lines (24 loc) · 1.29 KB
/
post_install_cleanup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
### this will remove the folders from %appdatalocal% for each user account on a given computer and then recreate the ARDUPILOT-configurator folder and place a text file in that folder. The script checks for this file and if it exsists will simply exit.
## because this checks each and every user on the windows machine ps will kick out some errors for any user that it doesnt have permission to access there local app data folder. these can be ignored.
#check for file
$txtfilepath = "C:\Users\$($_.Name)\AppData\Local\ARDUPILOT-configurator\check.txt"
$testpath = test-path $txtfilepath
if ($testpath -eq $true){
$append = "Terminated at time xxxxx"
$append | out-file $txtfilepath -append -force
break
}
else{
#continue script
# Get users
$users = Get-ChildItem -Path "C:\Users"
# Loop through users and delete the folder
$users | foreach-Object {
Remove-Item -Recurse -Path "C:\Users\$($_.Name)\AppData\Local\ARDUPILOT-configurator" -Force
}
}
#create new ARDUPILOT-configurator folder
New-Item -Path "C:\Users\$($_.Name)\AppData\Local\" -name "ARDUPILOT-configurator" -ItemType "directory"
# add text file to check for
New-Item -Path "C:\Users\$($_.Name)\AppData\Local\ARDUPILOT-configurator" -name "check.txt" -ItemType "file" -Value "config cleared"
break