Packaging HTA as EXE publishing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.