@@ -168,7 +168,7 @@ if ($Script:AccountOptionsCSV -ne $null){
168
168
}
169
169
if ($Entry.PW.length -eq 0 ){# if csv has account details but password field has been left blank
170
170
write-host
171
- write-host (" The account " + $Entry.AccountLabel + " Does not currently have a password defined." ) - foregroundcolor yellow
171
+ write-host (" The account " + $Entry.AccountLabel + " doesn't yet have a password defined." ) - foregroundcolor yellow
172
172
write-host
173
173
$Entry.pw = read-host - AsSecureString " Enter the Battle.net password for" $Entry.AccountLabel
174
174
$Entry.pw = $Entry.pw | ConvertFrom-SecureString
@@ -524,14 +524,15 @@ Function ChooseRegion {#AKA Realm. Not to be confused with the actual Diablo ser
524
524
}
525
525
526
526
Function Processing {
527
+
527
528
if (($script :pw -eq " " -or $script :pw -eq $null ) -and $script :pwmanualset -eq 0 ){
528
529
$script :pw = $Script :AccountChoice.pw.tostring ()
529
530
}
530
531
if ($script :ParamsUsed -ne $true -and $ConvertPlainTextPasswords -ne $false ){
531
532
$script :acct = $Script :AccountChoice.acct.tostring ()
532
533
$encryptedPassword = $pw | ConvertTo-SecureString
533
- $pw = New-Object System.Management.Automation.PsCredential(" N/A" , $encryptedPassword )
534
- $script :pw = $pw .GetNetworkCredential ().Password
534
+ $pwobject = New-Object System.Management.Automation.PsCredential(" N/A" , $encryptedPassword )
535
+ $script :pw = $pwobject .GetNetworkCredential ().Password
535
536
}
536
537
else {
537
538
$script :acct = $script :AccountUsername
@@ -548,25 +549,32 @@ Function Processing {
548
549
# Open diablo with parameters
549
550
# IE, this is essentially just opening D2r like you would with a shortcut target of "C:\Program Files (x86)\Battle.net\Games\Diablo II Resurrected\D2R.exe" -username <yourusername -password <yourPW> -address <SERVERaddress>
550
551
$arguments = (" -username " + $script :acct + " -password " + $script :PW + " -address " + $Script :Region ).tostring()
552
+ $script :pw = $null
551
553
# write-output $arguments #debug
552
554
Start-Process " $Gamepath \D2R.exe" - ArgumentList " $arguments "
553
- start-sleep - milliseconds 1500
554
-
555
+ start-sleep - milliseconds 1250 # give D2r a bit of a chance to start up before trying to kill handle
555
556
# Close the 'Check for other instances' handle
556
557
Write-host " Attempting to close `" Check for other instances`" handle..."
557
- $maxattempts = 5 # try closing 20 times.
558
+ $attempt = 0
559
+ $maxattempts = 10 # try closing x amount of times.
558
560
do {# wait for d2r process to start
561
+ # $output = "test" #debug
562
+ # $handlekilled = $true #debug
563
+ $attempt = $attempt + 1
564
+ write-host (" Attempt " + $attempt + " of $maxattempts " + " ...." )
559
565
$output = killhandle | out-string
560
- start-sleep - milliseconds 1000
561
566
if (($output.contains (" DiabloII Check For Other Instances" )) -eq $true ){
562
567
$handlekilled = $true
563
- $attempt = $attempt + 1
564
- write-host (" Attempt " + $attempt + " ...." )
565
568
write-host " Check for Other Instances Handle closed." - foregroundcolor green
566
- }
569
+ }
570
+ else {
571
+ start-sleep - milliseconds 1000 # if handle couldn't be closed give it another second before trying again.
572
+ }
567
573
} until ($handlekilled -eq $True -or $attempt -eq $maxattempts )
568
574
if ($attempt -eq $maxattempts ){
569
575
Write-Host " Couldn't find any handles to kill." - foregroundcolor red
576
+ Write-Host " Game may not have launched as expected." - foregroundcolor red
577
+ pause
570
578
}
571
579
# Rename the Diablo Game window for easier identification of which account and region the game is.
572
580
$rename = ($Script :AccountID + " - Diablo II: Resurrected - " + $Script :AccountFriendlyName + " (" + $Script :Region + " )" )
@@ -579,6 +587,7 @@ Function Processing {
579
587
}
580
588
catch {
581
589
write-host " Couldn't rename window :(" - foregroundcolor red
590
+ pause
582
591
}
583
592
start-sleep - milliseconds 100
584
593
$Script :ScriptHasBeenRun = $true
0 commit comments