Initial commit: Inno Setup installer packages

Installer packages for GE manufacturing tools:
- BlueSSOFix: Blue SSO authentication fix
- HIDCardPrinter: HID card printer setup
- HPOfflineInstaller: HP printer offline installer
- MappedDrive: Network drive mapping
- PrinterInstaller: General printer installer
- ShopfloorConnect: Shopfloor connectivity tool
- XeroxOfflineInstaller: Xerox printer offline installer

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-30 13:15:54 -05:00
commit 28541cd3ed
1175 changed files with 127441 additions and 0 deletions

469
MappedDrive/MappedDrive.iss Normal file
View File

@@ -0,0 +1,469 @@
; Script for GE Aerospace Mapped Drive Reconnection Utility
; Helps users update credentials and reconnect mapped drives
[Setup]
AppId={{C7D8E9F0-A1B2-3C4D-5E6F-7A8B9C0D1E2F}
AppName=WJDT GE Aerospace Mapped Drive Reconnection
AppVersion=1.1
AppPublisher=WJDT
AppPublisherURL=http://tsgwp00524.logon.ds.ge.com
AppSupportURL=http://tsgwp00524.logon.ds.ge.com
AppUpdatesURL=http://tsgwp00524.logon.ds.ge.com
CreateAppDir=no
ChangesAssociations=no
PrivilegesRequired=admin
OutputDir=C:\Users\570005354\Downloads\Output
OutputBaseFilename=MappedDriveReconnect
SolidCompression=yes
WizardStyle=modern
SetupIconFile=gea-logo.ico
WizardImageFile=patrick.bmp
WizardSmallImageFile=patrick-sm.bmp
CreateUninstallRegKey=no
DisableWelcomePage=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Messages]
WelcomeLabel2=This utility will help you reconnect your mapped network drives with updated credentials.%n%nYou will be prompted to enter your password for the logon domain. Your Windows username will be detected automatically.%n%nThis is useful when:%n- Your password has changed (90-day policy)%n- Drives have disconnected%n- Credentials need to be updated
[Code]
function SetEnvironmentVariable(lpName: String; lpValue: String): Boolean;
external 'SetEnvironmentVariableW@kernel32.dll stdcall';
var
PasswordPage: TInputQueryWizardPage;
ServerSelectionPage: TInputOptionWizardPage;
CurrentUsername: String;
UserPassword: String;
procedure InitializeWizard();
begin
CurrentUsername := GetUserNameString;
ServerSelectionPage := CreateInputOptionPage(wpWelcome,
'Select Servers to Reconnect',
'Choose which network drives you need to reconnect',
'Select the servers below. You can choose one or both depending on your needs.',
False, False);
ServerSelectionPage.Add('tsgwp00525.rd.ds.ge.com (Shared Drive)');
ServerSelectionPage.Add('win.cighpeifep036.logon.ds.ge.com (Engineering Server)');
ServerSelectionPage.Values[0] := True;
ServerSelectionPage.Values[1] := False;
PasswordPage := CreateInputQueryPage(ServerSelectionPage.ID,
'Enter Network Credentials',
'Please enter your password for the logon domain',
'Your username will be: logon\' + CurrentUsername + #13#10#13#10 +
'Enter your password below:');
PasswordPage.Add('Password:', True);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
ScriptPath: String;
PowerShellScript: String;
Server1Selected: Boolean;
Server2Selected: Boolean;
SelectedServers: String;
begin
Result := True;
if CurPageID = ServerSelectionPage.ID then
begin
if not (ServerSelectionPage.Values[0] or ServerSelectionPage.Values[1]) then
begin
MsgBox('Please select at least one server to reconnect.', mbError, MB_OK);
Result := False;
Exit;
end;
end;
if CurPageID = PasswordPage.ID then
begin
UserPassword := PasswordPage.Values[0];
if Trim(UserPassword) = '' then
begin
MsgBox('Password cannot be empty. Please enter your password.', mbError, MB_OK);
Result := False;
Exit;
end;
SelectedServers := '';
if ServerSelectionPage.Values[0] then
SelectedServers := SelectedServers + '- tsgwp00525.rd.ds.ge.com' + #13#10;
if ServerSelectionPage.Values[1] then
SelectedServers := SelectedServers + '- win.cighpeifep036.logon.ds.ge.com' + #13#10;
if MsgBox('Username: logon\' + CurrentUsername + #13#10#13#10 +
'Selected servers:' + #13#10 + SelectedServers + #13#10 +
'Are you ready to reconnect your mapped drives?',
mbConfirmation, MB_YESNO) = IDNO then
begin
Result := False;
Exit;
end;
end;
if CurPageID = wpReady then
begin
Server1Selected := ServerSelectionPage.Values[0];
Server2Selected := ServerSelectionPage.Values[1];
PowerShellScript :=
'$username = "logon\' + CurrentUsername + '"' + #13#10 +
'$password = [System.Environment]::GetEnvironmentVariable("TEMP_GE_PASSWORD","Process")' + #13#10 +
'[System.Environment]::SetEnvironmentVariable("TEMP_GE_PASSWORD",$null,"Process")' + #13#10 +
'$allSuccess = $true' + #13#10 +
'$mappingsFile = "$env:APPDATA\GEDriveMappings.json"' + #13#10 +
'' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host " GE Aerospace Drive Reconnection Tool" -ForegroundColor Cyan' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host ""' + #13#10 +
'Write-Host "Backing up current network mappings..." -ForegroundColor Yellow' + #13#10 +
'$currentMappings = @()' + #13#10 +
'$netUseOutput = net use | Select-String ":"' + #13#10 +
'foreach ($line in $netUseOutput) {' + #13#10 +
' if ($line -match "^[^\s]+\s+([A-Z]:)\s+(\\\\[^\s]+)\s+") {' + #13#10 +
' $driveLetter = $matches[1]' + #13#10 +
' $drivePath = $matches[2]' + #13#10 +
' if (-not ($currentMappings | Where-Object { $_.Drive -eq $driveLetter })) {' + #13#10 +
' $currentMappings += @{Drive=$driveLetter; Path=$drivePath}' + #13#10 +
' Write-Host " ${driveLetter} -> ${drivePath}" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'$existingBackup = @()' + #13#10 +
'if (Test-Path $mappingsFile) {' + #13#10 +
' try {' + #13#10 +
' $loaded = Get-Content $mappingsFile -Raw | ConvertFrom-Json' + #13#10 +
' if ($loaded) {' + #13#10 +
' if ($loaded -is [System.Array]) {' + #13#10 +
' $existingBackup = $loaded' + #13#10 +
' } else {' + #13#10 +
' $existingBackup = @($loaded)' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' if ($existingBackup.Count -gt 26) {' + #13#10 +
' Write-Host " Warning: Backup file corrupted, starting fresh" -ForegroundColor Yellow' + #13#10 +
' $existingBackup = @()' + #13#10 +
' }' + #13#10 +
' } catch {' + #13#10 +
' $existingBackup = @()' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'$mergedMappings = @{}' + #13#10 +
'foreach ($current in $currentMappings) {' + #13#10 +
' $mergedMappings[$current.Drive] = $current.Path' + #13#10 +
'}' + #13#10 +
'foreach ($existing in $existingBackup) {' + #13#10 +
' if (-not $mergedMappings.ContainsKey($existing.Drive)) {' + #13#10 +
' $mergedMappings[$existing.Drive] = $existing.Path' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'$mappingsToSave = @()' + #13#10 +
'foreach ($key in $mergedMappings.Keys) {' + #13#10 +
' $mappingsToSave += @{Drive=$key; Path=$mergedMappings[$key]}' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'if ($mappingsToSave.Count -gt 0) {' + #13#10 +
' $mappingsToSave | ConvertTo-Json -Depth 10 | Out-File -FilePath $mappingsFile -Encoding UTF8 -Force' + #13#10 +
' Write-Host " Saved $($mappingsToSave.Count) mappings" -ForegroundColor Green' + #13#10 +
' if ($existingBackup.Count -gt 0 -and $mappingsToSave.Count -gt $currentMappings.Count) {' + #13#10 +
' $preserved = $mappingsToSave.Count - $currentMappings.Count' + #13#10 +
' Write-Host " Preserved $preserved disconnected drive(s)" -ForegroundColor Yellow' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'Write-Host "Step 1: Checking for ghost drives..." -ForegroundColor Yellow' + #13#10;
if Server1Selected then
PowerShellScript := PowerShellScript +
'$job = Start-Job -ScriptBlock { net use S: 2>&1 }' + #13#10 +
'Wait-Job $job -Timeout 3 | Out-Null' + #13#10 +
'Remove-Job $job -Force 2>$null | Out-Null' + #13#10;
if Server2Selected then
PowerShellScript := PowerShellScript +
'$job = Start-Job -ScriptBlock { net use Y: 2>&1 }' + #13#10 +
'Wait-Job $job -Timeout 3 | Out-Null' + #13#10 +
'Remove-Job $job -Force 2>$null | Out-Null' + #13#10;
PowerShellScript := PowerShellScript +
'Write-Host " Done" -ForegroundColor Gray' + #13#10 +
'Write-Host ""' + #13#10 +
'Write-Host "Step 2: Disconnecting drives..." -ForegroundColor Yellow' + #13#10;
if Server1Selected then
PowerShellScript := PowerShellScript +
'$tsgwpConnections = Get-WmiObject Win32_NetworkConnection -ErrorAction SilentlyContinue | Where-Object { $_.RemoteName -like "*tsgwp00525*" }' + #13#10 +
'if ($tsgwpConnections) {' + #13#10 +
' $tsgwpConnections | ForEach-Object {' + #13#10 +
' Write-Host " $($_.LocalName)" -ForegroundColor Gray' + #13#10 +
' net use $_.LocalName /delete /yes 2>$null | Out-Null' + #13#10 +
' }' + #13#10 +
'}' + #13#10;
if Server2Selected then
PowerShellScript := PowerShellScript +
'net use Y: /delete /yes 2>$null | Out-Null' + #13#10 +
'Write-Host " Y:" -ForegroundColor Gray' + #13#10;
PowerShellScript := PowerShellScript +
'Write-Host ""' + #13#10 +
'Write-Host "Step 3: Updating credentials..." -ForegroundColor Yellow' + #13#10;
if Server1Selected then
PowerShellScript := PowerShellScript +
'cmdkey /delete:tsgwp00525.rd.ds.ge.com 2>$null | Out-Null' + #13#10 +
'cmdkey /add:tsgwp00525.rd.ds.ge.com /user:$username /pass:$password | Out-Null' + #13#10 +
'Write-Host " tsgwp00525" -ForegroundColor Green' + #13#10;
if Server2Selected then
PowerShellScript := PowerShellScript +
'cmdkey /delete:win.cighpeifep036.logon.ds.ge.com 2>$null | Out-Null' + #13#10 +
'cmdkey /add:win.cighpeifep036.logon.ds.ge.com /user:$username /pass:$password | Out-Null' + #13#10 +
'Write-Host " win.cighpeifep036" -ForegroundColor Green' + #13#10;
PowerShellScript := PowerShellScript +
'Start-Sleep -Seconds 1' + #13#10 +
'Write-Host ""' + #13#10;
if Server1Selected then
PowerShellScript := PowerShellScript +
'Write-Host "Step 4: Restoring tsgwp00525 drives..." -ForegroundColor Yellow' + #13#10 +
'$otherDrives = @()' + #13#10 +
'if (Test-Path $mappingsFile) {' + #13#10 +
' try {' + #13#10 +
' $allMappings = Get-Content $mappingsFile -Raw | ConvertFrom-Json' + #13#10 +
' if ($allMappings -is [System.Array]) {' + #13#10 +
' $otherDrives = @($allMappings | Where-Object { $_.Path -like "*tsgwp00525*" -and $_.Drive -ne "S:" })' + #13#10 +
' } else {' + #13#10 +
' if ($allMappings.Path -like "*tsgwp00525*" -and $allMappings.Drive -ne "S:") {' + #13#10 +
' $otherDrives = @($allMappings)' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' } catch { }' + #13#10 +
'}' + #13#10 +
'if ($otherDrives.Count -gt 0) {' + #13#10 +
' foreach ($drive in $otherDrives) {' + #13#10 +
' $driveLetter = $drive.Drive' + #13#10 +
' $drivePath = $drive.Path' + #13#10 +
' Write-Host " Restoring ${driveLetter}..." -ForegroundColor Gray' + #13#10 +
' $result = net use $driveLetter $drivePath /user:$username $password /persistent:yes 2>&1' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success" -ForegroundColor Green' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Failed: $result" -ForegroundColor Red' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
'} else {' + #13#10 +
' Write-Host " No additional drives to restore" -ForegroundColor Gray' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10;
PowerShellScript := PowerShellScript +
'Write-Host "Step 5: Mapping primary drives..." -ForegroundColor Yellow' + #13#10 +
'Write-Host ""' + #13#10;
if Server1Selected then
PowerShellScript := PowerShellScript +
'Write-Host " Mapping S:..." -ForegroundColor Cyan' + #13#10 +
'$maxRetries = 3' + #13#10 +
'$retryCount = 0' + #13#10 +
'$mapped = $false' + #13#10 +
'$authFailed = $false' + #13#10 +
'' + #13#10 +
'while (-not $mapped -and $retryCount -lt $maxRetries) {' + #13#10 +
' $retryCount++' + #13#10 +
' Write-Host " Attempt $retryCount..." -ForegroundColor Gray' + #13#10 +
' $mapResult = net use S: \\tsgwp00525.rd.ds.ge.com\shared /user:$username $password /persistent:yes 2>&1' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success!" -ForegroundColor Green' + #13#10 +
' $mapped = $true' + #13#10 +
' } elseif ($mapResult -like "*85*" -or $mapResult -like "*already in use*") {' + #13#10 +
' Write-Host " Ghost drive detected - cleaning up..." -ForegroundColor Yellow' + #13#10 +
' for ($i=1; $i -le 5; $i++) { net use S: /delete /yes 2>$null | Out-Null; Start-Sleep -Milliseconds 300 }' + #13#10 +
' if (Test-Path "HKCU:\Network\S") { Remove-Item "HKCU:\Network\S" -Recurse -Force -ErrorAction SilentlyContinue }' + #13#10 +
' Get-WmiObject Win32_NetworkConnection -ErrorAction SilentlyContinue | Where-Object { $_.LocalName -eq "S:" } | ForEach-Object { $_.Delete() }' + #13#10 +
' if (Get-PSDrive S -ErrorAction SilentlyContinue) { Remove-PSDrive S -Force -ErrorAction SilentlyContinue }' + #13#10 +
' if ($retryCount -eq 2) {' + #13#10 +
' Write-Host " Restarting Explorer..." -ForegroundColor Yellow' + #13#10 +
' Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue' + #13#10 +
' Start-Sleep -Seconds 2' + #13#10 +
' Start-Process explorer' + #13#10 +
' Start-Sleep -Seconds 2' + #13#10 +
' }' + #13#10 +
' Start-Sleep -Seconds 3' + #13#10 +
' } elseif ($mapResult -like "*1219*") {' + #13#10 +
' Write-Host " Resolving credential conflict..." -ForegroundColor Yellow' + #13#10 +
' $savedDrives = @()' + #13#10 +
' if (Test-Path $mappingsFile) {' + #13#10 +
' $allMappings = @(Get-Content $mappingsFile -Raw | ConvertFrom-Json)' + #13#10 +
' $savedDrives = @($allMappings | Where-Object { $_.Path -like "*tsgwp00525*" -and $_.Drive -ne "S:" })' + #13#10 +
' }' + #13#10 +
' Get-WmiObject Win32_NetworkConnection -ErrorAction SilentlyContinue | Where-Object { $_.RemoteName -like "*tsgwp00525*" } | ForEach-Object { net use $_.LocalName /delete /yes 2>$null | Out-Null }' + #13#10 +
' cmdkey /delete:tsgwp00525.rd.ds.ge.com 2>$null | Out-Null' + #13#10 +
' cmdkey /add:tsgwp00525.rd.ds.ge.com /user:$username /pass:$password | Out-Null' + #13#10 +
' Start-Sleep -Seconds 1' + #13#10 +
' foreach ($drive in $savedDrives) {' + #13#10 +
' net use $drive.Drive $drive.Path /user:$username $password /persistent:yes 2>$null | Out-Null' + #13#10 +
' }' + #13#10 +
' } else {' + #13#10 +
' if ($mapResult -like "*1326*" -or $mapResult -like "*1244*" -or $mapResult -like "*86*" -or $mapResult -like "*logon failure*" -or $mapResult -like "*password*" -or $mapResult -like "*access*denied*") {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkRed"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host " AUTHENTICATION FAILED" -ForegroundColor Red' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " The password is incorrect or your" -ForegroundColor Yellow' + #13#10 +
' Write-Host " account may need attention." -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Visit: https://oneidm.ge.com" -ForegroundColor Cyan' + #13#10 +
' Write-Host " to verify or change your password." -ForegroundColor Cyan' + #13#10 +
' Write-Host ""' + #13#10 +
' $authFailed = $true' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Error: $mapResult" -ForegroundColor Red' + #13#10 +
' $authFailed = $true' + #13#10 +
' }' + #13#10 +
' $allSuccess = $false' + #13#10 +
' $password = $null' + #13#10 +
' Write-Host " Press any key to exit..." -ForegroundColor Gray' + #13#10 +
' $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "Black"' + #13#10 +
' break' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'if (-not $mapped -and -not $authFailed) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkRed"' + #13#10 +
' Clear-Host' + #13#10 +
' $allSuccess = $false' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host " GHOST DRIVE DETECTED" -ForegroundColor Red' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Could not map S: after $retryCount attempts." -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " To fix:" -ForegroundColor Yellow' + #13#10 +
' Write-Host " 1. Save your work" -ForegroundColor White' + #13#10 +
' Write-Host " 2. Restart your computer" -ForegroundColor White' + #13#10 +
' Write-Host " 3. Run this tool again" -ForegroundColor White' + #13#10 +
' Write-Host ""' + #13#10 +
' $password = $null' + #13#10 +
' Write-Host " Press any key to exit..." -ForegroundColor Gray' + #13#10 +
' $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "Black"' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10;
if Server2Selected then
PowerShellScript := PowerShellScript +
'Write-Host " Checking Y: configuration..." -ForegroundColor Cyan' + #13#10 +
'$yWasOnTsgwp = $false' + #13#10 +
'if (Test-Path $mappingsFile) {' + #13#10 +
' $savedMappings = @(Get-Content $mappingsFile -Raw | ConvertFrom-Json)' + #13#10 +
' $yMapping = $savedMappings | Where-Object { $_.Drive -eq "Y:" }' + #13#10 +
' if ($yMapping -and $yMapping.Path -like "*tsgwp00525*") {' + #13#10 +
' $yWasOnTsgwp = $true' + #13#10 +
' Write-Host " Y: already configured for tsgwp00525" -ForegroundColor Yellow' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'if (-not $yWasOnTsgwp) {' + #13#10 +
' Write-Host " Mapping Y:..." -ForegroundColor Cyan' + #13#10 +
' $mapResult = net use Y: \\win.cighpeifep036.logon.ds.ge.com\ugcam_res_lib\library\database /user:$username $password /persistent:yes 2>&1' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success!" -ForegroundColor Green' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Failed: $mapResult" -ForegroundColor Red' + #13#10 +
' $allSuccess = $false' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10;
PowerShellScript := PowerShellScript +
'if ($allSuccess) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkGreen"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Cyan' + #13#10 +
' Write-Host " SUCCESS!" -ForegroundColor Cyan' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Cyan' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Connected drives:" -ForegroundColor White' + #13#10 +
' net use | Select-String ":" | ForEach-Object {' + #13#10 +
' if ($_ -match "([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' Write-Host " $($matches[1]) -> $($matches[2])" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Updating backup..." -ForegroundColor Yellow' + #13#10 +
' $finalMappings = @()' + #13#10 +
' $existingBackup = @()' + #13#10 +
' if (Test-Path $mappingsFile) {' + #13#10 +
' $existingBackup = @(Get-Content $mappingsFile -Raw | ConvertFrom-Json)' + #13#10 +
' }' + #13#10 +
' $netUseOutput = net use | Select-String ":"' + #13#10 +
' foreach ($line in $netUseOutput) {' + #13#10 +
' if ($line -match "([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' $finalMappings += @{Drive=$matches[1]; Path=$matches[2]}' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' foreach ($existing in $existingBackup) {' + #13#10 +
' if (-not ($finalMappings | Where-Object { $_.Drive -eq $existing.Drive })) {' + #13#10 +
' $finalMappings += $existing' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' if ($finalMappings.Count -gt 0) {' + #13#10 +
' $finalMappings | ConvertTo-Json -Depth 10 | Out-File -FilePath $mappingsFile -Encoding UTF8 -Force' + #13#10 +
' Write-Host " Backup updated" -ForegroundColor Green' + #13#10 +
' }' + #13#10 +
' Write-Host ""' + #13#10 +
' $password = $null' + #13#10 +
' Write-Host " Press any key to close..." -ForegroundColor Gray' + #13#10 +
' $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "Black"' + #13#10 +
'}';
ScriptPath := ExpandConstant('{tmp}\MapDrives.ps1');
SaveStringToFile(ScriptPath, PowerShellScript, False);
SetEnvironmentVariable('TEMP_GE_PASSWORD', UserPassword);
if not Exec('powershell.exe',
'-NoProfile -ExecutionPolicy Bypass -File "' + ScriptPath + '"',
'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Failed to execute script.', mbError, MB_OK);
Result := False;
end;
SetEnvironmentVariable('TEMP_GE_PASSWORD', '');
DeleteFile(ScriptPath);
end;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
end;
end;

View File

@@ -0,0 +1,434 @@
; Enhanced Script for GE Aerospace Mapped Drive Reconnection Utility
; Features:
; - AppData backup checked first (before scanning current drives)
; - Timeout detection (>6 seconds warns about credentials)
; - Authentication failure warnings with oneidm.ge.com link
; - Persistent drive mapping across reboots
[Setup]
AppId={{C7D8E9F0-A1B2-3C4D-5E6F-7A8B9C0D1E2F}
AppName=WJDT GE Aerospace Mapped Drive Reconnection
AppVersion=3.0
AppPublisher=WJDT
AppPublisherURL=http://tsgwp00524.logon.ds.ge.com
AppSupportURL=http://tsgwp00524.logon.ds.ge.com
AppUpdatesURL=http://tsgwp00524.logon.ds.ge.com
CreateAppDir=no
ChangesAssociations=no
PrivilegesRequired=admin
OutputDir=.\Output
OutputBaseFilename=MappedDriveReconnect_Enhanced
SolidCompression=yes
WizardStyle=modern
SetupIconFile=gea-logo.ico
WizardImageFile=patrick.bmp
WizardSmallImageFile=patrick-sm.bmp
CreateUninstallRegKey=no
DisableWelcomePage=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Messages]
WelcomeLabel2=This utility will reconnect your mapped network drives with updated credentials.%n%nProcess:%n1. Check for stored drive mappings%n2. Disconnect all current drives%n3. Update credentials%n4. Reconnect all drives%n%nYour drive mappings are preserved even after reboot.
[Code]
function SetEnvironmentVariable(lpName: String; lpValue: String): Boolean;
external 'SetEnvironmentVariableW@kernel32.dll stdcall';
var
PasswordPage: TInputQueryWizardPage;
CurrentUsername: String;
UserPassword: String;
procedure InitializeWizard();
begin
CurrentUsername := GetUserNameString;
PasswordPage := CreateInputQueryPage(wpWelcome,
'Enter Network Credentials',
'Please enter your password for the logon domain',
'Your username: logon\' + CurrentUsername + #13#10#13#10 +
'Enter your password below:');
PasswordPage.Add('Password:', True);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
ScriptPath: String;
PowerShellScript: String;
begin
Result := True;
if CurPageID = PasswordPage.ID then
begin
UserPassword := PasswordPage.Values[0];
if Trim(UserPassword) = '' then
begin
MsgBox('Password cannot be empty. Please enter your password.', mbError, MB_OK);
Result := False;
Exit;
end;
if MsgBox('Username: logon\' + CurrentUsername + #13#10#13#10 +
'Ready to update credentials and reconnect drives?',
mbConfirmation, MB_YESNO) = IDNO then
begin
Result := False;
Exit;
end;
end;
if CurPageID = wpReady then
begin
PowerShellScript :=
'# Enhanced Drive Reconnection Script v3.0' + #13#10 +
'$username = "logon\' + CurrentUsername + '"' + #13#10 +
'$password = [System.Environment]::GetEnvironmentVariable("TEMP_GE_PASSWORD","Process")' + #13#10 +
'[System.Environment]::SetEnvironmentVariable("TEMP_GE_PASSWORD",$null,"Process")' + #13#10 +
'$mappingsFile = "$env:APPDATA\GEDriveMappings.json"' + #13#10 +
'$slowConnectionWarned = $false' + #13#10 +
'' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host " GE Drive Reconnection Tool v3.0" -ForegroundColor Cyan' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 1: Check AppData for Stored Mappings' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 1: Checking for stored drive mappings..." -ForegroundColor Yellow' + #13#10 +
'$savedDrives = @()' + #13#10 +
'' + #13#10 +
'if (Test-Path $mappingsFile) {' + #13#10 +
' try {' + #13#10 +
' $loaded = Get-Content $mappingsFile -Raw | ConvertFrom-Json' + #13#10 +
' if ($loaded) {' + #13#10 +
' if ($loaded -is [System.Array]) {' + #13#10 +
' $savedDrives = @($loaded)' + #13#10 +
' } else {' + #13#10 +
' $savedDrives = @($loaded)' + #13#10 +
' }' + #13#10 +
' Write-Host " Found backup file with $($savedDrives.Count) drive(s)" -ForegroundColor Green' + #13#10 +
' foreach ($drive in $savedDrives) {' + #13#10 +
' Write-Host " $($drive.Drive) -> $($drive.Path)" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' } catch {' + #13#10 +
' Write-Host " Warning: Could not read backup file" -ForegroundColor Yellow' + #13#10 +
' $savedDrives = @()' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'# If no backup exists, scan current drives' + #13#10 +
'if ($savedDrives.Count -eq 0) {' + #13#10 +
' Write-Host " No backup found - scanning current drives..." -ForegroundColor Yellow' + #13#10 +
' $netUseOutput = net use 2>&1' + #13#10 +
' ' + #13#10 +
' foreach ($line in $netUseOutput) {' + #13#10 +
' if ($line -match "^\w+\s+([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' $drive = $matches[1]' + #13#10 +
' $path = $matches[2]' + #13#10 +
' $savedDrives += @{Drive=$drive; Path=$path}' + #13#10 +
' Write-Host " Found: $drive -> $path" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' ' + #13#10 +
' if ($savedDrives.Count -eq 0) {' + #13#10 +
' Write-Host " No mapped drives found" -ForegroundColor Gray' + #13#10 +
' } else {' + #13#10 +
' # Save to AppData for future use' + #13#10 +
' Write-Host " Saving to backup file..." -ForegroundColor Yellow' + #13#10 +
' $savedDrives | ConvertTo-Json -Depth 10 | Out-File -FilePath $mappingsFile -Encoding UTF8 -Force' + #13#10 +
' Write-Host " Backup created" -ForegroundColor Green' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 2: Disconnect All Mapped Drives' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 2: Disconnecting all mapped drives..." -ForegroundColor Yellow' + #13#10 +
'$currentDrives = @()' + #13#10 +
'$netUseOutput = net use 2>&1' + #13#10 +
'foreach ($line in $netUseOutput) {' + #13#10 +
' if ($line -match "^\w+\s+([A-Z]:)") {' + #13#10 +
' $currentDrives += $matches[1]' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'if ($currentDrives.Count -gt 0) {' + #13#10 +
' foreach ($drive in $currentDrives) {' + #13#10 +
' Write-Host " Disconnecting $drive..." -ForegroundColor Gray' + #13#10 +
' net use $drive /delete /yes 2>&1 | Out-Null' + #13#10 +
' }' + #13#10 +
' Write-Host " All drives disconnected" -ForegroundColor Green' + #13#10 +
'} else {' + #13#10 +
' Write-Host " No drives currently connected" -ForegroundColor Gray' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 3: Extract Unique Hostnames' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 3: Identifying unique servers..." -ForegroundColor Yellow' + #13#10 +
'$uniqueServers = @()' + #13#10 +
'' + #13#10 +
'foreach ($drive in $savedDrives) {' + #13#10 +
' if ($drive.Path -match "^\\\\([^\\]+)") {' + #13#10 +
' $hostname = $matches[1]' + #13#10 +
' if ($uniqueServers -notcontains $hostname) {' + #13#10 +
' $uniqueServers += $hostname' + #13#10 +
' Write-Host " Found server: $hostname" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'if ($uniqueServers.Count -eq 0) {' + #13#10 +
' Write-Host " No servers to connect to" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host "Nothing to do. Press any key to exit..." -ForegroundColor Yellow' + #13#10 +
' $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
' exit 0' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 4: Clear Old Credentials' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 4: Removing old credentials..." -ForegroundColor Yellow' + #13#10 +
'foreach ($server in $uniqueServers) {' + #13#10 +
' Write-Host " Clearing: $server" -ForegroundColor Gray' + #13#10 +
' cmdkey /delete:$server 2>&1 | Out-Null' + #13#10 +
'}' + #13#10 +
'Write-Host " Old credentials removed" -ForegroundColor Green' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 5: Add New Credentials' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 5: Adding new credentials..." -ForegroundColor Yellow' + #13#10 +
'foreach ($server in $uniqueServers) {' + #13#10 +
' Write-Host " Adding: $server" -ForegroundColor Gray' + #13#10 +
' $result = cmdkey /add:$server /user:$username /pass:$password 2>&1' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success!" -ForegroundColor Green' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Warning: $result" -ForegroundColor Yellow' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 6: Reconnect Drives with Monitoring' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 6: Reconnecting drives..." -ForegroundColor Yellow' + #13#10 +
'$successCount = 0' + #13#10 +
'$failCount = 0' + #13#10 +
'$authFailed = $false' + #13#10 +
'' + #13#10 +
'foreach ($drive in $savedDrives) {' + #13#10 +
' Write-Host " Mapping $($drive.Drive) -> $($drive.Path)..." -ForegroundColor Cyan' + #13#10 +
' ' + #13#10 +
' # Measure connection time' + #13#10 +
' $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()' + #13#10 +
' $mapResult = net use $($drive.Drive) $($drive.Path) /persistent:yes 2>&1' + #13#10 +
' $stopwatch.Stop()' + #13#10 +
' $elapsed = $stopwatch.Elapsed.TotalSeconds' + #13#10 +
' ' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success! (${elapsed}s)" -ForegroundColor Green' + #13#10 +
' $successCount++' + #13#10 +
' ' + #13#10 +
' # Warn if connection was slow' + #13#10 +
' if ($elapsed -gt 6 -and -not $slowConnectionWarned) {' + #13#10 +
' $slowConnectionWarned = $true' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host " SLOW CONNECTION WARNING" -ForegroundColor Yellow' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Connection took ${elapsed}s (>6s threshold)" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " This may indicate:" -ForegroundColor White' + #13#10 +
' Write-Host " - Credentials being validated slowly" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Network connectivity issues" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Server performance problems" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " If you see this repeatedly, verify" -ForegroundColor White' + #13#10 +
' Write-Host " your password at:" -ForegroundColor White' + #13#10 +
' Write-Host " https://oneidm.ge.com" -ForegroundColor Cyan' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Start-Sleep -Seconds 3' + #13#10 +
' }' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Failed (${elapsed}s)" -ForegroundColor Red' + #13#10 +
' ' + #13#10 +
' # Check for authentication errors' + #13#10 +
' if ($mapResult -like "*1326*" -or $mapResult -like "*1244*" -or ' + #13#10 +
' $mapResult -like "*86*" -or $mapResult -like "*logon failure*" -or ' + #13#10 +
' $mapResult -like "*password*" -or $mapResult -like "*access*denied*") {' + #13#10 +
' ' + #13#10 +
' $authFailed = $true' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkRed"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host " AUTHENTICATION FAILED" -ForegroundColor Red' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " The password is incorrect or your" -ForegroundColor Yellow' + #13#10 +
' Write-Host " account may need attention." -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Error: $mapResult" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Visit: https://oneidm.ge.com" -ForegroundColor Cyan' + #13#10 +
' Write-Host " to verify or change your password." -ForegroundColor Cyan' + #13#10 +
' Write-Host ""' + #13#10 +
' $password = $null' + #13#10 +
' Write-Host " Press any key to exit..." -ForegroundColor Gray' + #13#10 +
' $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "Black"' + #13#10 +
' exit 1' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Error: $mapResult" -ForegroundColor Red' + #13#10 +
' $failCount++' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'# Clear password from memory' + #13#10 +
'$password = $null' + #13#10 +
'' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 7: Update Backup with Final State' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 7: Updating backup file..." -ForegroundColor Yellow' + #13#10 +
'$finalMappings = @()' + #13#10 +
'' + #13#10 +
'# Get all currently connected drives' + #13#10 +
'$netUseOutput = net use 2>&1' + #13#10 +
'foreach ($line in $netUseOutput) {' + #13#10 +
' if ($line -match "^\w+\s+([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' $finalMappings += @{Drive=$matches[1]; Path=$matches[2]}' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'# Merge with drives that failed (keep them for next time)' + #13#10 +
'foreach ($saved in $savedDrives) {' + #13#10 +
' $alreadyConnected = $finalMappings | Where-Object { $_.Drive -eq $saved.Drive }' + #13#10 +
' if (-not $alreadyConnected) {' + #13#10 +
' $finalMappings += $saved' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'if ($finalMappings.Count -gt 0) {' + #13#10 +
' $finalMappings | ConvertTo-Json -Depth 10 | Out-File -FilePath $mappingsFile -Encoding UTF8 -Force' + #13#10 +
' Write-Host " Backup updated ($($finalMappings.Count) drive(s))" -ForegroundColor Green' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 8: Display Results' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "DEBUG: successCount=$successCount failCount=$failCount" -ForegroundColor Magenta' + #13#10 +
'Start-Sleep -Milliseconds 500' + #13#10 +
'if ($failCount -eq 0 -and $successCount -gt 0) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkGreen"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Green' + #13#10 +
' Write-Host " SUCCESS!" -ForegroundColor Green' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Green' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " All $successCount drive(s) reconnected successfully!" -ForegroundColor White' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Current mapped drives:" -ForegroundColor Yellow' + #13#10 +
' net use | Select-String ":" | ForEach-Object {' + #13#10 +
' if ($_ -match "([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' Write-Host " $($matches[1]) -> $($matches[2])" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' Write-Host ""' + #13#10 +
'} elseif ($failCount -gt 0 -and $successCount -gt 0) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkYellow"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host " PARTIAL SUCCESS" -ForegroundColor Yellow' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Successfully reconnected: $successCount drive(s)" -ForegroundColor Green' + #13#10 +
' Write-Host " Failed to reconnect: $failCount drive(s)" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Failed drives have been saved and will" -ForegroundColor White' + #13#10 +
' Write-Host " be retried next time you run this tool." -ForegroundColor White' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Possible reasons for failure:" -ForegroundColor White' + #13#10 +
' Write-Host " - Incorrect password" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Server unreachable" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Share no longer exists" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
'} elseif ($failCount -gt 0 -and $successCount -eq 0) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkRed"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host " ALL DRIVES FAILED" -ForegroundColor Red' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Failed to reconnect: $failCount drive(s)" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Possible reasons:" -ForegroundColor White' + #13#10 +
' Write-Host " - Incorrect password" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Server unreachable" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Network connectivity issues" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Visit: https://oneidm.ge.com" -ForegroundColor Cyan' + #13#10 +
' Write-Host " to verify or change your password." -ForegroundColor Cyan' + #13#10 +
' Write-Host ""' + #13#10 +
'} else {' + #13#10 +
' Write-Host " No drives were reconnected" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'Write-Host " Press any key to close..." -ForegroundColor Gray' + #13#10 +
'$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
'$Host.UI.RawUI.BackgroundColor = "Black"';
ScriptPath := ExpandConstant('{tmp}\MapDrives_Enhanced.ps1');
SaveStringToFile(ScriptPath, PowerShellScript, False);
SetEnvironmentVariable('TEMP_GE_PASSWORD', UserPassword);
if not Exec('powershell.exe',
'-NoProfile -ExecutionPolicy Bypass -File "' + ScriptPath + '"',
'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Failed to execute script.', mbError, MB_OK);
Result := False;
end;
SetEnvironmentVariable('TEMP_GE_PASSWORD', '');
DeleteFile(ScriptPath);
end;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
end;
end;

View File

@@ -0,0 +1,270 @@
; Simplified Script for GE Aerospace Mapped Drive Reconnection Utility
; Clean approach: Record → Disconnect → Update Credentials → Reconnect
[Setup]
AppId={{C7D8E9F0-A1B2-3C4D-5E6F-7A8B9C0D1E2F}
AppName=WJDT GE Aerospace Mapped Drive Reconnection
AppVersion=2.0
AppPublisher=WJDT
AppPublisherURL=http://tsgwp00524.logon.ds.ge.com
AppSupportURL=http://tsgwp00524.logon.ds.ge.com
AppUpdatesURL=http://tsgwp00524.logon.ds.ge.com
CreateAppDir=no
ChangesAssociations=no
PrivilegesRequired=admin
OutputDir=C:\Users\570005354\Downloads\Output
OutputBaseFilename=MappedDriveReconnect_v2
SolidCompression=yes
WizardStyle=modern
SetupIconFile=gea-logo.ico
WizardImageFile=patrick.bmp
WizardSmallImageFile=patrick-sm.bmp
CreateUninstallRegKey=no
DisableWelcomePage=no
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Messages]
WelcomeLabel2=This utility will update your network drive credentials and reconnect all mapped drives.%n%nSimple process:%n1. Record current drives%n2. Disconnect all drives%n3. Update credentials%n4. Reconnect drives%n%nYou will be prompted for your logon domain password.
[Code]
function SetEnvironmentVariable(lpName: String; lpValue: String): Boolean;
external 'SetEnvironmentVariableW@kernel32.dll stdcall';
var
PasswordPage: TInputQueryWizardPage;
CurrentUsername: String;
UserPassword: String;
procedure InitializeWizard();
begin
CurrentUsername := GetUserNameString;
PasswordPage := CreateInputQueryPage(wpWelcome,
'Enter Network Credentials',
'Please enter your password for the logon domain',
'Your username: logon\' + CurrentUsername + #13#10#13#10 +
'Enter your password below:');
PasswordPage.Add('Password:', True);
end;
function NextButtonClick(CurPageID: Integer): Boolean;
var
ResultCode: Integer;
ScriptPath: String;
PowerShellScript: String;
begin
Result := True;
if CurPageID = PasswordPage.ID then
begin
UserPassword := PasswordPage.Values[0];
if Trim(UserPassword) = '' then
begin
MsgBox('Password cannot be empty. Please enter your password.', mbError, MB_OK);
Result := False;
Exit;
end;
if MsgBox('Username: logon\' + CurrentUsername + #13#10#13#10 +
'Ready to update credentials and reconnect drives?',
mbConfirmation, MB_YESNO) = IDNO then
begin
Result := False;
Exit;
end;
end;
if CurPageID = wpReady then
begin
PowerShellScript :=
'# Simplified Drive Reconnection Script' + #13#10 +
'$username = "logon\' + CurrentUsername + '"' + #13#10 +
'$password = [System.Environment]::GetEnvironmentVariable("TEMP_GE_PASSWORD","Process")' + #13#10 +
'[System.Environment]::SetEnvironmentVariable("TEMP_GE_PASSWORD",$null,"Process")' + #13#10 +
'' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host " GE Drive Reconnection Tool v2.0" -ForegroundColor Cyan' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 1: Record Current Mapped Drives' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 1: Recording current mapped drives..." -ForegroundColor Yellow' + #13#10 +
'$savedDrives = @()' + #13#10 +
'$netUseOutput = net use 2>&1' + #13#10 +
'' + #13#10 +
'foreach ($line in $netUseOutput) {' + #13#10 +
' # Match pattern: "Status Local Remote Network"' + #13#10 +
' # "OK S: \\server\share Microsoft..."' + #13#10 +
' if ($line -match "^\w+\s+([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' $drive = $matches[1]' + #13#10 +
' $path = $matches[2]' + #13#10 +
' $savedDrives += @{Drive=$drive; Path=$path}' + #13#10 +
' Write-Host " Found: $drive -> $path" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'if ($savedDrives.Count -eq 0) {' + #13#10 +
' Write-Host " No mapped drives found" -ForegroundColor Gray' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 2: Disconnect All Mapped Drives' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 2: Disconnecting all mapped drives..." -ForegroundColor Yellow' + #13#10 +
'foreach ($drive in $savedDrives) {' + #13#10 +
' Write-Host " Disconnecting $($drive.Drive)..." -ForegroundColor Gray' + #13#10 +
' net use $($drive.Drive) /delete /yes 2>&1 | Out-Null' + #13#10 +
'}' + #13#10 +
'Write-Host " All drives disconnected" -ForegroundColor Green' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 3: Extract Unique Hostnames' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 3: Identifying unique servers..." -ForegroundColor Yellow' + #13#10 +
'$uniqueServers = @()' + #13#10 +
'' + #13#10 +
'foreach ($drive in $savedDrives) {' + #13#10 +
' # Extract hostname from \\hostname\share' + #13#10 +
' if ($drive.Path -match "^\\\\([^\\]+)") {' + #13#10 +
' $hostname = $matches[1]' + #13#10 +
' if ($uniqueServers -notcontains $hostname) {' + #13#10 +
' $uniqueServers += $hostname' + #13#10 +
' Write-Host " Found server: $hostname" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 4: Delete Old Credentials' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 4: Removing old credentials from Windows Credential Manager..." -ForegroundColor Yellow' + #13#10 +
'foreach ($server in $uniqueServers) {' + #13#10 +
' Write-Host " Deleting credentials for: $server" -ForegroundColor Gray' + #13#10 +
' cmdkey /delete:$server 2>&1 | Out-Null' + #13#10 +
'}' + #13#10 +
'Write-Host " Old credentials removed" -ForegroundColor Green' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 5: Add New Credentials' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 5: Adding new credentials to Windows Credential Manager..." -ForegroundColor Yellow' + #13#10 +
'foreach ($server in $uniqueServers) {' + #13#10 +
' Write-Host " Adding credentials for: $server" -ForegroundColor Gray' + #13#10 +
' $result = cmdkey /add:$server /user:$username /pass:$password 2>&1' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success!" -ForegroundColor Green' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Warning: $result" -ForegroundColor Yellow' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'Write-Host ""' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 6: Reconnect Drives (Auto-Auth)' + #13#10 +
'# ============================================' + #13#10 +
'Write-Host "Step 6: Reconnecting drives (using stored credentials)..." -ForegroundColor Yellow' + #13#10 +
'$successCount = 0' + #13#10 +
'$failCount = 0' + #13#10 +
'' + #13#10 +
'foreach ($drive in $savedDrives) {' + #13#10 +
' Write-Host " Mapping $($drive.Drive) -> $($drive.Path)..." -ForegroundColor Cyan' + #13#10 +
' ' + #13#10 +
' # Let Windows pull credentials automatically from Credential Manager' + #13#10 +
' $mapResult = net use $($drive.Drive) $($drive.Path) /persistent:yes 2>&1' + #13#10 +
' ' + #13#10 +
' if ($LASTEXITCODE -eq 0) {' + #13#10 +
' Write-Host " Success!" -ForegroundColor Green' + #13#10 +
' $successCount++' + #13#10 +
' } else {' + #13#10 +
' Write-Host " Failed: $mapResult" -ForegroundColor Red' + #13#10 +
' $failCount++' + #13#10 +
' }' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'# Clear password from memory' + #13#10 +
'$password = $null' + #13#10 +
'' + #13#10 +
'Write-Host ""' + #13#10 +
'Write-Host "========================================" -ForegroundColor Cyan' + #13#10 +
'' + #13#10 +
'# ============================================' + #13#10 +
'# STEP 7: Display Results' + #13#10 +
'# ============================================' + #13#10 +
'if ($failCount -eq 0) {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkGreen"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Green' + #13#10 +
' Write-Host " SUCCESS!" -ForegroundColor Green' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Green' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " All $successCount drive(s) reconnected successfully!" -ForegroundColor White' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Current mapped drives:" -ForegroundColor Yellow' + #13#10 +
' net use | Select-String ":" | ForEach-Object {' + #13#10 +
' if ($_ -match "([A-Z]:)\s+(\\\\[^\s]+)") {' + #13#10 +
' Write-Host " $($matches[1]) -> $($matches[2])" -ForegroundColor Gray' + #13#10 +
' }' + #13#10 +
' }' + #13#10 +
' Write-Host ""' + #13#10 +
'} else {' + #13#10 +
' $Host.UI.RawUI.BackgroundColor = "DarkYellow"' + #13#10 +
' Clear-Host' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host " PARTIAL SUCCESS" -ForegroundColor Yellow' + #13#10 +
' Write-Host " ========================================" -ForegroundColor Yellow' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Successfully reconnected: $successCount drive(s)" -ForegroundColor Green' + #13#10 +
' Write-Host " Failed to reconnect: $failCount drive(s)" -ForegroundColor Red' + #13#10 +
' Write-Host ""' + #13#10 +
' Write-Host " Possible reasons for failure:" -ForegroundColor White' + #13#10 +
' Write-Host " - Incorrect password" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Server unreachable" -ForegroundColor Gray' + #13#10 +
' Write-Host " - Share no longer exists" -ForegroundColor Gray' + #13#10 +
' Write-Host ""' + #13#10 +
'}' + #13#10 +
'' + #13#10 +
'Write-Host " Press any key to close..." -ForegroundColor Gray' + #13#10 +
'$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")' + #13#10 +
'$Host.UI.RawUI.BackgroundColor = "Black"' + #13#10;
ScriptPath := ExpandConstant('{tmp}\MapDrives_v2.ps1');
SaveStringToFile(ScriptPath, PowerShellScript, False);
SetEnvironmentVariable('TEMP_GE_PASSWORD', UserPassword);
if not Exec('powershell.exe',
'-NoProfile -ExecutionPolicy Bypass -File "' + ScriptPath + '"',
'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Failed to execute script.', mbError, MB_OK);
Result := False;
end;
SetEnvironmentVariable('TEMP_GE_PASSWORD', '');
DeleteFile(ScriptPath);
end;
end;
function ShouldSkipPage(PageID: Integer): Boolean;
begin
Result := False;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
end;
end;

BIN
MappedDrive/gea-logo.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
MappedDrive/patrick-sm.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
MappedDrive/patrick.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB