Jump to content

Delete files and clear eventlogs from remote pc


farma
 Share

Recommended Posts

Is it possible to delete and clear eventlog from a remote pc with Autoit?

I have administators rights on the remote pc

This is my batch I'm working with right now, but I still have to delete the eventviewer manual.

Is it possible to start the tool it asks me the PC-Name and delete and clear the eventlog automatical?

@ECHO OFF
IF "%1"=="" goto input
SET variable=%1
GOTO output

:input
ECHO         #########################
ECHO.
ECHO         !! Enter PC Name or IP !!   
ECHO.                                                           
ECHO         #########################
ECHO.   

ECHO.
SET /p variable=IP/PC-Name:
GOTO output

:output
cls
ECHO         ########################################
ECHO         Check PC-Name or IP 
ECHO         %variable%                  
ECHO         After pressing any key the files will be deleted
ECHO         ########################################
PAUSE

cls

del /F \\%variable%\c$\WINDOWS\system32\DWRCK.DLL
del /F \\%variable%\c$\WINDOWS\system32\DWRCS.EXE
del /F \\%variable%\c$\WINDOWS\system32\DWRCS.INI
del /F \\%variable%\c$\WINDOWS\system32\DWRCSET.DLL
del /F \\%variable%\c$\WINDOWS\system32\DWRCShell.dll


ECHO         ###################################
ECHO         The files are removed from %variable% 
ECHO                               
ECHO         ###################################

PAUSE
CLS

ECHO         ###############################
ECHO.                                                                  
ECHO         The Eventviewer from %variable% opens
ECHO.                                                                 
ECHO         ###############################

PAUSE
eventvwr %variable%
CLS
GOTO input
Link to comment
Share on other sites

Is it possible to delete and clear eventlog from a remote pc with Autoit?

I have administators rights on the remote pc

This is my batch I'm working with right now, but I still have to delete the eventviewer manual.

Is it possible to start the tool it asks me the PC-Name and delete and clear the eventlog automatical?

CODE
@ECHO OFF

IF "%1"=="" goto input

SET variable=%1

GOTO output

:input

ECHO #########################

ECHO.

ECHO !! Enter PC Name or IP !!

ECHO.

ECHO #########################

ECHO.

ECHO.

SET /p variable=IP/PC-Name:

GOTO output

:output

cls

ECHO ########################################

ECHO Check PC-Name or IP

ECHO %variable%

ECHO After pressing any key the files will be deleted

ECHO ########################################

PAUSE

cls

del /F \\%variable%\c$\WINDOWS\system32\DWRCK.DLL

del /F \\%variable%\c$\WINDOWS\system32\DWRCS.EXE

del /F \\%variable%\c$\WINDOWS\system32\DWRCS.INI

del /F \\%variable%\c$\WINDOWS\system32\DWRCSET.DLL

del /F \\%variable%\c$\WINDOWS\system32\DWRCShell.dll

ECHO ###################################

ECHO The files are removed from %variable%

ECHO

ECHO ###################################

PAUSE

CLS

ECHO ###############################

ECHO.

ECHO The Eventviewer from %variable% opens

ECHO.

ECHO ###############################

PAUSE

eventvwr %variable%

CLS

GOTO input

Assuming your shell script works fine with your permissions, just read the help file for AutoIT (which is also its command reference) and :

Replace 'set /p' with InputBox()

Replace the 'echo' with MsgBox()

Replace 'del /f' with FileDelete()

Anything you can get done in shell script can be done from AutoIT. Play with it and post your AutoIT code to the forum if you need more help.

:lmao:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Assuming your shell script works fine with your permissions, just read the help file for AutoIT (which is also its command reference) and :

Replace 'set /p' with InputBox()

Replace the 'echo' with MsgBox()

Replace 'del /f' with FileDelete()

Anything you can get done in shell script can be done from AutoIT. Play with it and post your AutoIT code to the forum if you need more help.

:lmao:

Thanks in advanced

OK,

I can enter the pc name and it also opens the eventviewer from the remote pc.

But how can I use the "filedelete" with the variable, the question if this is the right pc name also doesn't work!?!?! And I still have to delete/clear the eventviewer manual.

$remotepc=InputBox("Name or IP of the Remote PC?", "Type the NAME or IP of the Remote PC!")
If $remotepc = "" Then
    If @error = 1 Then
        MsgBox(0,"Cancel", "You cancel the program")
    ELSE    
    ENDIF
    EXIT
ENDIF
MsgBox(1,"Is it Correct?", "You typed in this Name/IP."& @CRLF & $remotepc)
IF @error >= 2 Then
        MsgBox(0,"No!!", "You cancel the program")
    ELSE    
        run("cmd")
        sleep(1000)
        Send("eventvwr "&  $remotepc)
        Send("{ENTER}")
        Send ("exit")
        Send("{ENTER}")
    EXIT
ENDIF
EXIT
Link to comment
Share on other sites

Hi,

i got it without filedelete!!!!

I there is something I don't like! That the CMD opens.

Can someone please take a look and tell me what i can make better?

Thanks in advance!!

#include <GUIConstants.au3>
$font="Comic Sans MS"

While 1
    GUICreate(" DWRC-Clean", 320,150,)
    GUICtrlCreateLabel ("IP or PC-Name?", 20,20)
    GUISetFont (-1,15,400)
    $remotepc =GUICtrlCreateInput ("127.0.0.1", 20, 40, 300, 20)
    $exit = GUICtrlCreateButton(" EXIT ", 100, 75) 
    GUICtrlCreateLabel ("by Thomas Gebauer", 190,85)
    $ok = GUICtrlCreateButton ("  OK  ", 20, 75)
    GUISetState(@SW_SHOW)
    While 2
        $msg = GUIGetMsg()
            Select
                Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
                Case $msg = $ok
                
                            
                GUICreate("This PC??", 320, 150,)
                GUICtrlCreateLabel ("Is this the correct one?", 5,20)
                GUISetFont (15,400)
                GUICtrlCreateLabel (""& GUICtrlRead($remotepc), 5,60)
                
                $no = GUICtrlCreateButton(" RESTART ", 100,100)
                $yes = GUICtrlCreateButton(" YES ", 30, 100)
                $done = GUICtrlCreateButton(" EXIT ", 230, 100)
                GUISetState(@SW_SHOW)

                While 2
                $msg = GUIGetMsg()
                Select
                    Case $msg = $GUI_EVENT_CLOSE
                    ExitLoop

                    Case $msg = $yes
                    MsgBox(0, "Button", "OK,..." & @CRLF & "Let's go...", 1.5)
                    SplashTextOn("Don't touch!", "DON'T TOUCH THE KEYBOARD OR THE MOUSE!", 500, 400, -1, -1, 0, "", 16)
                    Sleep(4000)
                    SplashOff()
                    run("cmd")
                    sleep(1000)
                    send("del /F \\"& GUICtrlRead($remotepc))
                    send("\c$\WINDOWS\system32\DWRC*")
                    send("{ENTER}")
                    sleep("8000")
                    Send("eventvwr "& GUICtrlRead($remotepc))
                    Send("{ENTER}")
                    Send("exit")
                    Send("{ENTER}")
                    Sleep(3000)
                    Send("{DOWN}!trn")
                    Sleep(500)
                    Send("{DOWN}!trn")
                    Sleep(500)
                    Send("{DOWN}!trn")
                    Sleep(500)
                    Send("{DOWN}!trn")
                    Send("!d+b")
                    MsgBox(0,"Finish", "The DWRC files should be deleted! And the Eventlog should be cleared!")

                    EXITLOOP
                    

                    Case $msg = $done
                                
                    GUIDelete()
                    EXIT
                    EXITLOOP


                    Case $msg = $no
                    GUIDelete()
                    MsgBox(0, "Button", "restart???" & @CRLF & "OK...", 1.5)
                    GUIDelete()
                    EXITLOOP
                    
                EndSelect
                
                $msg = $GUI_EVENT_CLOSE
                
                Wend    





                GUIDelete()

                Case $msg = $exit
                GUIDelete()
                EXIT        
            EndSelect
        $msg = $GUI_EVENT_CLOSE

    Wend
    GUIDelete()
EXITLOOP
            
                                
WEND
EXIT
Edited by farma
Link to comment
Share on other sites

Hi,

i got it without filedelete!!!!

I there is something I don't like! That the CMD opens.

Can someone please take a look and tell me what i can make better?

Thanks in advance!!

Seems like you went the hard way with the file deletions. The FileDelete() function works fine with variables and UNC paths, assuming you have the permissions to perform the operation:

$TargetComp = "Your_Comp_Name"
$TargetShare = "C$"
$TargetDir = "\Temp"
$TargetFiles = "*.tmp"

If FileDelete("\\" & $TargetComp & "\" & $TargetShare & $TargetDir & "\" & $TargetFiles) Then
     MsgBox(32, "Message", "Files deleted successfully.")
Else
     MsgBox(16, "Error", "Error deleting files!")
EndIf
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Seems like you went the hard way with the file deletions. The FileDelete() function works fine with variables and UNC paths, assuming you have the permissions to perform the operation:

$TargetComp = "Your_Comp_Name"
$TargetShare = "C$"
$TargetDir = "\Temp"
$TargetFiles = "*.tmp"

If FileDelete("\\" & $TargetComp & "\" & $TargetShare & $TargetDir & "\" & $TargetFiles) Then
     MsgBox(32, "Message", "Files deleted successfully.")
Else
     MsgBox(16, "Error", "Error deleting files!")
EndIf
Hi,

this doesn' t work I always get an error.

If FileDelete("\\" & $remotepc & "\c$\WINDOWS\system32\DWRC*.*") Then
                        MsgBox(32, "Message", "Files deleted successfully.")
                        Else
                        MsgBox(16, "Error", "Error deleting files!")
                    EndIf
Link to comment
Share on other sites

Hi,

this doesn' t work I always get an error.

If FileDelete("\\" & $remotepc & "\c$\WINDOWS\system32\DWRC*.*") Then
                        MsgBox(32, "Message", "Files deleted successfully.")
                        Else
                        MsgBox(16, "Error", "Error deleting files!")
                    EndIf
Try it this way to see how the path parsed and see if you need tweaking:

$DeletePath = "\\" & $remotepc & "\c$\WINDOWS\system32\DWRC*.*"
If FileDelete($DeletePath) Then
    MsgBox(32, "Message", "Files deleted successfully at:" & @CRLF & _
        @Tab & $DeletePath)
Else
    MsgBox(16, "Error", "Error deleting files at:" & @CRLF & _
        @Tab & $DeletePath)
EndIf
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

AHhh.... now it works

*brain on*

$DeletePath = "\\" & GUICtrlRead($remotepc) & "\c$\WINDOWS\system32\DWRC*.*"
                    If FileDelete($DeletePath) Then
                            MsgBox(0, "Message", "Files deleted successfully at:" & @CRLF &  @Tab & $DeletePath, 2)
                        Else
                        MsgBox(16, "Error", "Error deleting files at:" & @CRLF & @Tab & $DeletePath, 5)
                        EXITLOOP
                        EndIf

*brain off*

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...