Skip to content

Commit f989e8d

Browse files
authored
Enable silent mode setup for Windows #3076 (#3082)
* Add option to skip the questions during setup * Initialize correctly the answer variable
1 parent 8fe4465 commit f989e8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

setup/native-script.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
# @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
66
# To run it inside a WINDOWS POWERSHELL console against the production branch (only one supported with self-elevation) use
77
# start-process -FilePath PowerShell.exe -Verb Runas -Wait -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))"
8-
8+
param(
9+
[switch] $SilentMode
10+
)
911
# Check if latest .NET framework installed is at least 4
1012
$dotNetVersions = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version,Release -EA 0 | Where { $_.PSChildName -match '^(?!S)\p{L}'} | Select Version
1113
$latestDotNetVersion = $dotNetVersions.GetEnumerator() | Sort-Object Version | Select-Object -Last 1
@@ -27,7 +29,7 @@ if (-not $isElevated) {
2729
}
2830

2931
# Help with installing other dependencies
30-
$script:answer = ""
32+
$script:answer = if ($SilentMode) {"a"} else {""}
3133
function Install($programName, $message, $script, $shouldExit) {
3234
if ($script:answer -ne "a") {
3335
Write-Host -ForegroundColor Green "Allow the script to install $($programName)?"

0 commit comments

Comments
 (0)