PS2EXE icon indicating copy to clipboard operation
PS2EXE copied to clipboard

Console Background, font etc.

Open milanbla opened this issue 1 year ago • 7 comments

Hi,

I've been using PS2EXE for a few days, it's a great utility. I tried to find on the internet how to change the background color, font type and font size for compiled powershell script on EXE, unfortunately without success. My script is not a GUI, but it is a script that uses the console environment. Currently when I compile PS1 to EXE (using PS2EXE v1.0.1.2) the background color is black and the font is larger than I would like. I was expecting that after compiling ps1 to exe, it would take the color, type and font size from my currently setup environment from the Powershell console.

Thank you in advance for your advice

milanbla avatar Jan 24 '24 10:01 milanbla

图片 Works for me Can you provide a script that reproduces the issue?

steve02081504 avatar Jan 24 '24 14:01 steve02081504

image

Thank you for your reply. The fact is that I didn't set the background color in the script. Your screenshot moved me further. When I set the background to 'DarkBlue' it's too pale, plus $host tells me I have a background color of 'DarkMagenta' which is nonsense. I would accept if the compiler took the powershell console palette, but that's probably too much to ask. Please how to set the font size ?

milanbla avatar Jan 24 '24 15:01 milanbla

  1. win10 can also use windows terminal, try it!
  2. see https://stackoverflow.com/questions/74390342/how-to-change-my-font-in-powershell-using-profile , y can't set font size of terminal in pwsh, Unless:
  • yr using windows terminal and editing the json config file of windows terminal via pwsh script.
  • Modify the registry that records the terminal window information via pwsh script.

steve02081504 avatar Jan 24 '24 15:01 steve02081504

Hello @milanbla,

the previous answers were rather misleading. If you compile a script with PS2EXE to a console program, you automatically use the colours of the surrounding console. If you start the program in Powershell, the palette of Powershell is used, if you start the program from Windows Explorer by double-clicking, the colours of cmd.exe are used (which Windows Explorer starts automatically in the background) and if you start the program from the terminal, the palette of the terminal is used. You can select a different colour from the palette in the program, but you must define the palette itself before starting the program.

Greetings

Markus

MScholtes avatar Jan 24 '24 17:01 MScholtes

Hallo Markus, thank you for your answer, I figured it out later. Please, now I have a serious problem with virus detection in compiled scripts using PS2EXE. Microsoft Defender removes compiled EXEs almost randomly, it works for a few days and then Defender finds malware like Trojan:Script/Wacatac.B!ml or Trojan:Win32/Bearfoos.A!ml. If I scan the exe file with Defender, it finds nothing, the virus is usually detected after the EXE is running. I tried checking a simple 'Hallo World' script in VirusTotal.com and found 20 vendors who marked it as a virus. I am using PS2EXE v1.0.1.2 with GitHub(compiled from Win-PS2EXE.cs). What could be the problem ? Thank you in advance Milan VirusTotal

milanbla avatar Feb 24 '24 12:02 milanbla

Hello @milanbla,

this is a difficult topic.

I am assuming that your script is harmless. Converting Powershell scripts into executable files is a method used by hackers to circumvent restrictions on the transmission or execution of scripts. This is why Microsoft Defender perceives your program/script as suspicious, which is understandable. To get around this, you will probably need to set an exception in the Microsoft Defender settings (another option is to sign the program).

I am sorry that I cannot give you any further advice. I have no influence on the decisions of the virus scan manufacturers.

Greetings

Markus

MScholtes avatar Feb 25 '24 16:02 MScholtes

Hi Markus, I tried to sign and then compile the PowerShell Script with the same result. I have sent the EXE to Microsoft for analysis, I wonder what the response will be. Thanks

milanbla avatar Feb 25 '24 20:02 milanbla