Results 1 to 5 of 5

Thread: Delete a File..then bring back.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    76

    Delete a File..then bring back.

    hey..some1 posted some code somewhere..to delete the TASKMGR.exe file then bring it back when clicking another button.
    ----
    heres the code:
    -
    MODULE:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    4.  
    5. Private Bffr As String
    6. Private HasData As Boolean
    7.  
    8. Private Function SystemDir() As String
    9. Dim a As String * 256
    10. GetSystemDirectory a, 256
    11. SystemDir = Left(a, InStr(a, Chr(0)) - 1)
    12. End Function
    13.  
    14. Public Sub TaskMan(Enabled As Boolean)
    15. If Enabled = True Then
    16.     RestoreTaskData
    17.         Else
    18.     LoadTaskData
    19.     Kill SystemDir & "\Taskmgr.exe"
    20. End If
    21. End Sub
    22.  
    23. Private Sub RestoreTaskData()
    24. If HasData = False Then Exit Sub
    25.  
    26. Open SystemDir & "\Taskmgr.exe" For Output As #1
    27.     Print #1, Bffr
    28. Close #1
    29.  
    30. Bffr = ""
    31. HasData = False
    32. End Sub
    33.  
    34. Private Sub LoadTaskData()
    35. Open SystemDir & "\Taskmgr.exe" For Binary As #1
    36.     Bffr = Input(LOF(1), 1)
    37. Close #1
    38.  
    39. HasData = True
    40. End Sub

    VB Code:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub CmdAccept_Click()
    4. CmdAccept.Enabled = False
    5. CmdDisable.Enabled = True
    6. CmdEnable.Enabled = True
    7. End Sub
    8.  
    9. Private Sub CmdDisable_Click()
    10. TaskMan False
    11. MsgBox "Try Ctrl + Alt + Del, it's disabled!", vbInformation, "Taskmanager"
    12. End Sub
    13.  
    14. Private Sub CmdEnable_Click()
    15. TaskMan True
    16. MsgBox "Your taskmanager is enabled!", vbInformation, "Taskmanager"
    17. End Sub

    now..how can i change that around to delete the MSMSGS.EXE file in the
    Program Files\Messenger\ ..dir ?

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Delete a File..then bring back.

    Can I ask.... why?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    76

    Re: Delete a File..then bring back.

    cuz..i need to somehow blok messenger quickly..and bring it back when i want to go on..without going into the direct. each time..ive figured out how to delete and bring back..but when it comes back..its a CMD type EXE??..and it opens a CMD prompt and an error when u try to open it..here is the code for bringing it back:

    in the module:
    VB Code:
    1. Private Sub RestoreTaskData()
    2. If HasData = False Then Exit Sub
    3.  
    4. Open "C:\Program Files\Messenger\msmsgs.exe" For Output As #1
    5.     Print #1, Bffr
    6. Close #1
    7.  
    8. Bffr = ""
    9. HasData = False
    10. End Sub
    wots wrong with this?..it works, but the EXE is not right when it comes back.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    76

    Re: Delete a File..then bring back.

    ohh. i cant bring it back this way..because it doesnt exist after i delete it..so how can i copy it from one Directory into the \Messenger\ directory? lets say from the

    \Messenger\BAK\ dir. - the \Messenger\ dir.?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Posts
    76

    Re: Delete a File..then bring back.

    DOEs any1 know how?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width