hta在打開的時候,有時候會被殺毒軟件攔截而不給執行,更重要的一點是通常都可以右擊查看源代碼,里面如果涉及到域名或者其它的一些細節就很容易被其它人了解。
網絡上有一些hta轉exe的,類似的軟件基本上都是國外的,而且要付費,從一些亂七八糟的地方下載過“破解版”的用了一下,不是很好用,對hta支持比較差,對vbs可能會好很多,既然不好用那就只好自己動手了
很簡單,主要的實現過程是:將hta作為資源添加至項目中,exe啟動后讀取資源文件,並寫入本地磁盤,然后調用mshta命令啟動hta,當hta被關閉時刪除該文件。
讀取資源 --> 寫文件 --> 執行文件 --> 刪除文件
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
System.Resources.ResourceManager manager = Properties.Resources.ResourceManager;
Object target = manager.GetObject("test");
string strSystemPath = System.Environment.SystemDirectory;
string strSystemDisk = strSystemPath.Substring(0, 1);
string strHtaPath = strSystemDisk + ":\\temp.hta";
if (File.Exists(strHtaPath))
{
File.Delete(strHtaPath);
}
FileStream fs = new FileStream(strHtaPath, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(target.ToString());
sw.Flush();
sw.Close();
fs.Close();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "mshta.exe";
startInfo.Arguments = strHtaPath;
Process process = Process.Start(startInfo);
//一直等待直到進程被關閉
process.WaitForExit();
if (File.Exists(strHtaPath))
{
File.Delete(strHtaPath);
}
//MessageBox.Show("hahaniu");
//Application.Run();
}
exe的話就可以很方便的設定圖標了,如果hta也想有圖標,就再多獲取一個icon放釋放出來就好了,剩下自由發揮了。也許有更好的辦法,這個只是我簡單的一種嘗試…