When an HTA is opened, it is sometimes blocked by anti-virus software and not executed, and more importantly, it is often possible to right-click to view the source code, which can easily be understood by others if it involves a domain name or some other detail.
There are some HTA on the network to EXE, similar software is basically foreign, and to pay, from some messy place to download the "cracked version" of the use of, not very good, the HTA support is poor, the VBS may be a lot better, since the bad use that you have to do it yourself
Quite simply, the main implementation is to add the HTA as a resource to the project, EXE to read the resource file after startup, write to the local disk, and then invoke the Mshta command to start the HTA and delete the file when the HTA is closed.
Read resources--Write files--Execute files--delete files
{
Application.enablevisualstyles ();
Application.setcompatibletextrenderingdefault (false);
//application.run (New Form1 ());
System.Resources.ResourceManager manager = Properties.Resources.ResourceManager;
Object target = Manager. GetObject ("Test");
stringStrsystempath = System.Environment.SystemDirectory;
stringStrsystemdisk = strsystempath.substring (0, 1);
stringStrhtapath = Strsystemdisk +": \\temp.hta";
if(File.exists (Strhtapath))
{
File.delete (Strhtapath);
}
FileStream fs =NewFileStream (Strhtapath, FileMode.Create);
StreamWriter SW =NewStreamWriter (FS);
Sw. Write (target. ToString ());
Sw. Flush ();
Sw. Close ();
Fs. Close ();
ProcessStartInfo StartInfo =NewProcessStartInfo ();
Startinfo.filename ="Mshta.exe";
Startinfo.arguments = Strhtapath;
Process process = Process.Start (startinfo);
//Wait until the process is closed
Process. WaitForExit ();
if(File.exists (Strhtapath))
{
File.delete (Strhtapath);
}
//messagebox.show ("Hahaniu");
//application.run ();
}
EXE can be very convenient to set the icon, if the HTA also want to have icons, and then more to get an icon to release it, the rest of the free play. Maybe there is a better way, this is just my simple kind of try ...
Packaging HTA as EXE publishing