|
28 | 28 | import java.lang.reflect.Method; |
29 | 29 | import java.nio.file.Files; |
30 | 30 | import java.nio.file.Path; |
31 | | -import java.util.List; |
32 | 31 | import java.util.Optional; |
33 | 32 |
|
34 | 33 | public final class LauncherIconVerifier { |
@@ -136,18 +135,16 @@ private WinIconVerifier() { |
136 | 135 |
|
137 | 136 | private Path extractIconFromExecutable(Path outputDir, Path executable, |
138 | 137 | String label) { |
139 | | - Path psScript = outputDir.resolve(label + ".ps1"); |
140 | 138 | Path extractedIcon = outputDir.resolve(label + ".bmp"); |
141 | | - TKit.createTextFile(psScript, List.of( |
| 139 | + String script = String.join(";", |
142 | 140 | "[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing')", |
143 | 141 | String.format( |
144 | | - "[System.Drawing.Icon]::ExtractAssociatedIcon(\"%s\").ToBitmap().Save(\"%s\", [System.Drawing.Imaging.ImageFormat]::Bmp)", |
| 142 | + "[System.Drawing.Icon]::ExtractAssociatedIcon('%s').ToBitmap().Save('%s', [System.Drawing.Imaging.ImageFormat]::Bmp)", |
145 | 143 | executable.toAbsolutePath().normalize(), |
146 | | - extractedIcon.toAbsolutePath().normalize()), |
147 | | - "exit 0")); |
| 144 | + extractedIcon.toAbsolutePath().normalize())); |
148 | 145 |
|
149 | | - Executor.of("powershell", "-NoLogo", "-NoProfile", "-File", |
150 | | - psScript.toAbsolutePath().normalize().toString()).execute(); |
| 146 | + Executor.of("powershell", "-NoLogo", "-NoProfile", "-Command", |
| 147 | + script).execute(); |
151 | 148 |
|
152 | 149 | return extractedIcon; |
153 | 150 | } |
|
0 commit comments