-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup.ps1
More file actions
40 lines (31 loc) · 1.28 KB
/
Setup.ps1
File metadata and controls
40 lines (31 loc) · 1.28 KB
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
32
33
34
35
36
37
38
39
40
#Assemblies
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName PresentationCore,PresentationFramework
#Open choose directory dialog box
Do {
$Dia=[System.Windows.Forms.FolderBrowserDialog]::new()
$Dia.Description='Select the folders to be backuped up, click Cancel when done'
$Dia.Dispose()
$Dia.ShowDialog()
$SP=$Dia.SelectedPath
$SP | Out-File .\Folder\Source.txt -Append
} Until (-not $SP)
#For choosing destination folder
$Button=[System.Windows.MessageBoxButton]::OK
$Title="Notice"
$Body="Select the backup destination folder next"
$Icon=[System.Windows.MessageBoxImage]::Information
[System.Windows.MessageBox]::Show($body,$Title,$Button,$Icon)
$Dia.Description='Select backup folder (cloud or external drive)'
$Dia.ShowDialog()
$SD=$Dia.SelectedPath
$SD| Out-File .\Folder\Destination.txt
#Register script in Task Scheduler
[string]$WD= Get-Location
$TD = "$WD\Folder"
$Action= New-ScheduledTaskAction -Execute "$TD\Auto-Backup Script.exe" -WorkingDirectory "$TD"
$Trigger = New-ScheduledTaskTrigger -Daily -At 12am
$Settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -AllowStartIfOnBatteries
Register-ScheduledTask -TaskName 'BackupScript' -Action $Action -Trigger $Trigger -RunLevel Highest -Settings $Settings
Push-Location $TD
& '.\Auto-Backup Script.exe'