Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Need help on how to do the coding.

30 Jun 2015   #1
ShoTTaS

Windows 7 Pro 32bit
 
 
Need help on how to do the coding.

I have a log file in XML format that i want to delete through task scheduler.
I want to delete this because the logs accumulate every week and gets as big as 80GB. It affects the performance of the PC.

The file is located in C:\ProgramData\folder1\folder2\Logs Folder\ErrorLog.xml

can someone give a code on how to delete this using batch file. I only want to delete the ErrorLog.xml not the folder.

i already know how to run the batch file on task scheduler. i just don't know how to create the code.

Thank you


My System SpecsSystem Spec
.
30 Jun 2015   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

Let's save automatic file deletion via scheduled task as the last resort.

1) Have you tried to figure out why so many errors are being logged?

2) Have you tried telling that app to log fewer errors? (e.g. change debug/logging level)

3) Have you tried manually deleting the file, manually recreating the file, then making it read-only. If the app does not complain about not being able to log errors, then this might be a better solution than automated deletion. You can always temporarily remove the read-only attribute if you need to see the errors being logged.
My System SpecsSystem Spec
30 Jun 2015   #3
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Hi ShoTTaS,

You can schedule for cmd.exe to run the del command on that ErrorLog.xml file of yours.

E.g., In Task Scheduler you'd input cmd.exe as the Program/script and /c "del "C:\ProgramData\folder1\folder2\Logs Folder\ErrorLog.xml"" in the Add arguments (optional) field.


Quote   Quote: Originally Posted by ShoTTaS View Post
i already know how to run the batch file on task scheduler. i just don't know how to create the code.
There's no need for a batch file if you're running just a single command.
My System SpecsSystem Spec
.

30 Jun 2015   #4
ShoTTaS

Windows 7 Pro 32bit
 
 

hi Pyprohly,

Quote:
Hi ShoTTaS,

You can schedule for cmd.exe to run the del command on that ErrorLog.xml file of yours.

E.g., In Task Scheduler you'd input cmd.exe as the Program/script and /c "del "C:\ProgramData\folder1\folder2\Logs Folder\ErrorLog.xml"" in the Add arguments (optional) field.
what does /c stands for? i just want to know.

i will be using this command that you gave.

Thank you
My System SpecsSystem Spec
01 Jul 2015   #5
GokAy

Windows 7 Ultimate x64 SP1
 
 

See:

Quote:
/C Carries out the command specified by the string and then terminates.
My System SpecsSystem Spec
01 Jul 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

To further boost the understanding, this is what the full command you're running actually looks like, ShoTTaS --
Code:
cmd.exe /c "del "C:\ProgramData\folder1\folder2\Logs Folder\ErrorLog.xml""
As you see, the /c switch belongs to the Cmd command. We can observe the help information for the Cmd command to figure out what its switches are and do, by running the command cmd /?.
Code:
C:\>cmd /?
Starts a new instance of the Windows command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]
/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
[...]
My System SpecsSystem Spec
06 Jul 2015   #7
ShoTTaS

Windows 7 Pro 32bit
 
 

Quote   Quote: Originally Posted by Pyprohly View Post
To further boost the understanding, this is what the full command you're running actually looks like, ShoTTaS --
Code:
cmd.exe /c "del "C:\ProgramData\folder1\folder2\Logs Folder\ErrorLog.xml""
As you see, the /c switch belongs to the Cmd command. We can observe the help information for the Cmd command to figure out what its switches are and do, by running the command cmd /?.
Code:
C:\>cmd /?
Starts a new instance of the Windows command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [[/S] [/C | /K] string]
/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
/S      Modifies the treatment of string after /C or /K (see below)
/Q      Turns echo off
/D      Disable execution of AutoRun commands from registry (see below)
[...]
Thank you.
My System SpecsSystem Spec
Reply

 Need help on how to do the coding.




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
HTML Coding
HI when i try to save a file i made in the html web page it only saves the first <textarea> thing and not the the remaining here is the code i use : <html> <body> <table> <tr><td>Text to Save:</td></tr> <tr> <td colspan="3">
Browsers & Mail
[REQ] Coding Tutorial Website
As my adventures through Cisco begin, I've been wanting to expand my knowledge to make myself a more valuable employee. I've done some dabling in C++ when I was younger, but I've forgotten all that I learned. I'm looking for tutorials that start with the basics, and work towards the advanced/pro...
Chillout Room
Portable Coding Notepad...
I'm looking for a portable version of Notepad++ or something similar to it. I'm currently using Notepad++ but it doesn't have the compile feature for some reason, and it won't include things like "windows.h" or other things needed. I can't even save the HTML/PHP/CSS/PHP files either. ...
Chillout Room
Character coding problem on W7 Pro x64
First of all, I'm a Romanian and that's part of the reason I opened this thread. I used to run x86 on my notebook and after I've downloaded a movie, the sub was perfect with the correct characters (ă, ș, ț), aka Unicode. After I chenged to x64, the characters went crazy. I mean, for the SAME movie,...
General Discussion
Intros and coding
I'm new to the forums, hi! I have been coding for a while, and I end up writing apps for myself. So I figure what better place to tell people than the seven forums. This time I was learning the Windows 7 API, jump lists specifically. What was born was Linx, which you pin to your task bar,...
Chillout Room
Microsoft.NET and C# coding
HAve just taken up c# and downloaded MVisualStudio 9. This seems fine but tried to follow example for using command line entry using Notepad and a .NET builder called csc.exe Apparently this should have come with VS9 or .NET but .NET appears to be missing stuff as well. Can anybody give me an...
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 13:49.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App