Files
inno-installers/MappedDrive/MappedDrive_Enhanced.iss
cproudlock 8be52f956e 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>
2025-12-30 13:15:54 -05:00

435 lines
22 KiB
Plaintext

; 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;