How to delete a program

Source: Internet
Author: User
How to delete the program (Author: Zhu Xinbin, Zhao Xi 2005.2.27)

Private sub button#click (byval sender as system. Object, byval e as system. eventargs) handles button1.click

Dim delstring as string 'string of the batch file to be written

Dim appname as string

Appname = system. environment. getcommandlineargs (0). Replace (directory. getcurrentdirectory ()&"/","")

Delstring = "pause" & vbcrlf ', which can be changed. The batch processing file can be executed after a period of time. Otherwise, it cannot be deleted if the program is not exited.

Delstring + = "Del" & appname & vbcrlf 'to generate a program deletion command. The intermediate part is used to obtain the complete program path.

Delstring + = "del % 0" 'Delete the BAT file

 

Dim delbatfile as new filestream ("delme. Bat", filemode. Create) 'generates a bat batch file

Dim buffer (100) as byte

Buffer = system. Text. encoding. ASCII. getbytes (delstring. tochararray) 'converts a string to a byte stream

Delbatfile. Write (buffer, 0, buffer. Length) 'write to the BAT file

Delbatfile. Flush ()

Delbatfile. Close ()

Process. Start ("delme. Bat") 'executes batch processing files

Me. Close ()

End sub

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.