Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var psScript =
- "[Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\") | Out-Null\n" +
- "Add-Type @\"\n" +
- "using System;\n" +
- "using System.Runtime.InteropServices;\n" +
- "public class IconExtractor {\n" +
- " [DllImport(\"shell32.dll\", CharSet=CharSet.Auto)]\n" +
- " public static extern int ExtractIconEx(string file, int index, IntPtr[] large, IntPtr[] small, int icons);\n" +
- "}\n" +
- "\"@\n" +
- "$exePath = '" + exePath.replace(/'/g, "''") + "'\n" +
- "$icoPath = '" + icoPath.replace(/'/g, "''") + "'\n" +
- "$large = New-Object IntPtr[] 1\n" +
- "$small = New-Object IntPtr[] 1\n" +
- "[IconExtractor]::ExtractIconEx($exePath, 0, $large, $small, 1) | Out-Null\n" +
- "if ($large[0] -ne [IntPtr]::Zero) {\n" +
- " $icon = [System.Drawing.Icon]::FromHandle($large[0])\n" +
- " $fs = New-Object System.IO.FileStream($icoPath, [System.IO.FileMode]::Create)\n" +
- " $icon.Save($fs)\n" +
- " $fs.Close()\n" +
- "}";
- var cmd = "powershell.exe -Command \"" + psScript.replace(/"/g, '\\"') + "\"";
- shell.Run(cmd, 0, true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement