Advertisement
jimlkosmo

Untitled

Jun 27th, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. var psScript =
  2. "[Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\") | Out-Null\n" +
  3. "Add-Type @\"\n" +
  4. "using System;\n" +
  5. "using System.Runtime.InteropServices;\n" +
  6. "public class IconExtractor {\n" +
  7. " [DllImport(\"shell32.dll\", CharSet=CharSet.Auto)]\n" +
  8. " public static extern int ExtractIconEx(string file, int index, IntPtr[] large, IntPtr[] small, int icons);\n" +
  9. "}\n" +
  10. "\"@\n" +
  11. "$exePath = '" + exePath.replace(/'/g, "''") + "'\n" +
  12. "$icoPath = '" + icoPath.replace(/'/g, "''") + "'\n" +
  13. "$large = New-Object IntPtr[] 1\n" +
  14. "$small = New-Object IntPtr[] 1\n" +
  15. "[IconExtractor]::ExtractIconEx($exePath, 0, $large, $small, 1) | Out-Null\n" +
  16. "if ($large[0] -ne [IntPtr]::Zero) {\n" +
  17. " $icon = [System.Drawing.Icon]::FromHandle($large[0])\n" +
  18. " $fs = New-Object System.IO.FileStream($icoPath, [System.IO.FileMode]::Create)\n" +
  19. " $icon.Save($fs)\n" +
  20. " $fs.Close()\n" +
  21. "}";
  22.  
  23. var cmd = "powershell.exe -Command \"" + psScript.replace(/"/g, '\\"') + "\"";
  24. shell.Run(cmd, 0, true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement