# Stop the three services Get-Service -Name RSysLnkCns, RSysLogger, WksEmitter | Stop-Service -Force # Display a dialog box for the user to select a folder $selectedFolder = Get-Item -Path 'C:\borisconfig\*' | Out-GridView -PassThru -Title "Pick a Folder" # Get the list of config files in the selected folder $configs = Get-ChildItem -Path $selectedFolder.FullName -File # Check that the user has selected at least one config file if ($configs.Count -eq 0) { Write-Warning "No config files found in selected folder" pause exit } # Move the contents of the destination folder to a backup folder $backupDir = "C:\Rejsekort\Conf\OldConfig" if (!(Test-Path $backupDir)) { New-Item -ItemType Directory -Path $backupDir | Out-Null } Move-Item -Path "C:\Rejsekort\Conf\*" -Destination $backupDir -Force -ErrorAction SilentlyContinue # Copy the config files to the destination folder Copy-Item -Path $configs.FullName -Destination "C:\Rejsekort\Conf\" -Force # Get the selected choice from the user $choices = "buc", "preprod", "prod", "testa", "testc" $selectedChoice = $choices | Out-GridView -PassThru -Title "Pick a choice" # Modify the RSysLnkCns.exe.config file based on the selected choice $configFile = "C:\Rejsekort\Bin\RSysLnkCns.exe.config" if (Test-Path $configFile) { $config = Get-Content $configFile switch ($selectedChoice) { "buc" { $config[44] = ' ' } "preprod" { $config[44] = ' ' } "prod" { $config[44] = ' ' } "testc" { $config[44] = ' ' } "testa" { $config[44] = ' ' } } Set-Content $configFile -Value $config } else { Write-Warning "Could not find config file $configFile" pause exit } # Start the three services Get-Service -Name RSysLnkCns, RSysLogger, WksEmitter | Start-Service Add-Type -AssemblyName System.Windows.Forms [System.Windows.Forms.MessageBox]::Show('Please wait 1-2 minutes before trying to connect in order for the client to sync config', 'PlatformConfigScript')