diff --git a/Sandbox Scripts/InstallSoftware.cmd b/Sandbox Scripts/InstallSoftware.cmd index 6a588e2..0ddb9e2 100644 --- a/Sandbox Scripts/InstallSoftware.cmd +++ b/Sandbox Scripts/InstallSoftware.cmd @@ -1,4 +1,5 @@ -"C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\7zip.exe" /S +powershell -command 'Set-ExecutionPolicy Unrestricted' +powershell -command 'Unblock-File -Path "C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\prepare.ps1"' "C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\python3.exe" /S "C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\vlc.exe" /S curl -L "https://update.code.visualstudio.com/latest/win32-x64-user/stable" --output C:\users\WDAGUtilityAccount\Downloads\vscode.exe diff --git a/Sandbox Scripts/prepare.ps1 b/Sandbox Scripts/prepare.ps1 index d6d2df9..53fd092 100644 --- a/Sandbox Scripts/prepare.ps1 +++ b/Sandbox Scripts/prepare.ps1 @@ -4,13 +4,27 @@ #Copy items to desktop Copy-Item './extract.py' '..'; -Get-ChildItem | Where-Object { $_.name -match '\.zip'} | ForEach-Object {Copy-Item -Path $_.name -Destination '..' } +#Get-ChildItem | Where-Object { $_.name -match '\.zip'} | ForEach-Object {Copy-Item -Path $_.name -Destination '..' } #Capture zip password from filename $pwPattern = [regex] "[A-z 0-9 \-]{1,251}\((?[A-z0-9]{1,251})\)\.zip"; +$files = @{}; +Get-ChildItem './Sandbox Scripts'| Where-Object { $_.name -match '\.zip'} | ForEach-Object { + $pass = [Regex]::Matches($_, $pwPattern); + $files.Add($_.name, $pass.groups[1].Value); +} -$files = Get-ChildItem; -$passwords = [Regex]::Matches($files, $pwPattern); -$passwords.groups | Where-Object {$_.Name -match "PW"} | ForEach-Object {Write-Output $_.Value } +#Install 7Zip and extract the zip files to the desktop. +Write-Output "Installing Programs..."; +Start-Process "C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\7zip.exe" -NoNewWindow -Wait -ArgumentList /S; +$sevenZip = "C:\Program Files\7-Zip\7z.exe"; +foreach ($file in $files.GetEnumerator()){ + Write-Output "Extracting $($file.Name)"; + $archivePath = "C:\Users\WDAGUtilityAccount\Desktop\Sandbox Scripts\$($file.Name)" + $outputPath = "C:\Users\WDAGUtilityAccount\Desktop\$($file.Name)"; + $password = $($file.Value); + $arguments = "$($archivePath)", "-o$($outputPath)", "-p$($password)"; + &$sevenZip e $arguments; +} Write-Output Done; \ No newline at end of file