본문 바로가기

자료

[C#,VB.net]자기자신 파일삭제(selfKill)

728x90

 

블로그 인기글

● 메이플스토리 신규 룬패치/자동해제 프로그램 [링크 이동]

● 메이플스토리 거짓말탐지기 알림 프로그램 [링크 이동]

C#에서 TensorFlow 사용하는법 [링크 이동]


Dim cTarget = System.Windows.Forms.Application.StartupPath & "\Kill.bat"
Dim strBat

strBat = _
"@echo off" & vbCrLf & _
"echo. Self Kill" & vbCrLf & _
":retry" & vbCrLf & _
"IF NOT EXIST " & Chr(34) & System.Windows.Forms.Application.ExecutablePath & Chr(34) & " goto end" & vbCrLf & _
"attrib " & Chr(34) & System.Windows.Forms.Application.ExecutablePath & Chr(34) & " -h -r -s" & vbCrLf & _
"del " & Chr(34) & System.Windows.Forms.Application.ExecutablePath & Chr(34) & vbCrLf & _
"IF EXIST " & Chr(34) & System.Windows.Forms.Application.ExecutablePath & Chr(34) & " goto retry" & vbCrLf & _
"@echo on" & vbCrLf & _
"cls" & vbCrLf & _
"del %0" & vbCrLf & _
"exit"

Dim swriter As New System.IO.StreamWriter(cTarget, True, Encoding.ASCII)
swriter.Write(strBat)
swriter.Close()

Dim sFullPathToFile As String
sFullPathToFile = System.Windows.Forms.Application.ExecutablePath
Try
Process.Start(cTarget)
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & ex.ToString)
End Try

End
728x90