我想再程序里面点一个按钮(比如移除按钮)就可以将该程序的exe文件从硬盘上删除,用VB不知道怎么实现,情各位大虾帮忙!谢谢先!

解决方案 »

  1.   

    只能用自删除批处理。Option ExplicitPrivate Sub Form_Unload(Cancel As Integer)
        Dim i As Integer
        Dim strBatFile As String
        
        strBatFile = App.Path & "\" & App.EXEName & ".bat"
        i = FreeFile
        Open strBatFile For Output Access Write As #i
        Print #i, "Sleep 10"
        Print #i, "Del """ & App.Path & "\" & App.EXEName & ".exe"""
        Print #i, "Del """ & strBatFile & """"
        Close (i)
        Shell Environ$("comspec") & " /c """ & strBatFile & """", vbMinimizedFocus
        EndEnd Sub