PS2EXE
PS2EXE copied to clipboard
Console Background, font etc.
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
Works for me
Can you provide a script that reproduces the issue?
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 ?
- win10 can also use windows terminal, try it!
- 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.
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
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
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
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