將hta包裝為exe發布

2021-09-08 10:55:50 字數 1405 閱讀 8283

hta在開啟的時候,有時候會被防毒軟體攔截而不給執行,更重要的一點是通常都可以右擊檢視源**,裡面如果涉及到網域名稱或者其它的一些細節就很容易被其它人了解。

很簡單,主要的實現過程是:將hta作為資源新增至專案中,exe啟動後讀取資源檔案,並寫入本地磁碟,然後呼叫mshta命令啟動hta,當hta被關閉時刪除該檔案。

讀取資源 --> 寫檔案 --> 執行檔案 --> 刪除檔案

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))

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))

"hahaniu");}

exe的話就可以很方便的設定圖示了,如果hta也想有圖示,就再多獲取乙個icon放釋放出來就好了,剩下自由發揮了。也許有更好的辦法,這個只是我簡單的一種嘗試…

如何將bat指令碼包裝為Windows服務之後啟動

參考自 準備事項 1 新建bat指令碼,裡面編輯需要執行的命令 本例 d restfuljars start material restful.bat 部署windows服務 3 將2個工具包拷貝到d盤根目錄下 4 執行命令,建立windows服務 d instsrv.exe restful esb...

將mongodb安裝為windows服務

解壓到自己喜歡的乙個目錄 d nosql mongodb 配置mongodb home環境變數 mongodb home d nosql mongodb mongodb win32 i386 2.0.6 修改path變數值 在最後加上 mongodb home bin 編寫安裝批處理語句 語句中不存...

把第三方jar檔案包裝為plugin

前面說過,輸出eclipse外掛程式的時候問題比較多 google搜尋3rd party jars site dev.eclipse.org 特別是使用了第三方jar檔案的時候。有乙個比較方便的辦法是把這些jar檔案包裝為乙個單獨的外掛程式,然後 你的功能外掛程式用dependencies的方式引用...