Our November Competition
User Reviews - Add Yours!
The PCHF Lounge
Go Back   PC Help Forum » Software » Programming
Register for a Free Account

Programming - exporting results from batch file posted in the Software forums; Hi there, I am trying to achieve a pretty simple task here, i'm just cant seem to think how to do what i want properly though... I currently have a ...


Reply
Free PC Performance Scan
Old 04-08-2009   #1
Bronze Member
 
Join Date: Apr 2009
Posts: 3
PC Experience: Experienced
Default exporting results from batch file

Hi there, I am trying to achieve a pretty simple task here, i'm just cant seem to think how to do what i want properly though...

I currently have a batch file that looks like the following:
@echo off
color 91
DEL /F file.exe
DEL /F file.exe
DEL /F file.exe >log.txt

basicly it attempts to delete the same file a few times in a row.
I've tried to make it so it creates a log with the results, but it didnt seem to work...

I would like to have it check for when it has success, then creates a log with the "file has been successfully deleted" message that comes up after it, then have it exit the batch file.

Then If it does not have success by the end of the batch, I want it to create a log with the error.



Is there anyone who has experience in batch file creation that could help me out here?
pure_evil020 is offline   Reply With Quote
Advertisement - Register to Remove
Old 04-08-2009   #2
Moderator
 
Sir Trews's Avatar
 
Join Date: Mar 2006
Location: Where ever my 18 wheels take me!
Posts: 2,536
PC Experience: Always Learning
Default Re: exporting results from batch file

Yup.. there are ones that can help you PE.

It all depends on what you propose to do with this.

A little more information would help.

__________________
Saesa omentien lle
(Pleasure meeting you)
Sir Trews is offline   Reply With Quote
Old 04-08-2009   #3
Bronze Member
 
Join Date: Apr 2009
Posts: 3
PC Experience: Experienced
Default Re: exporting results from batch file

Originally Posted by Sir Trews View Post
Yup.. there are ones that can help you PE.

It all depends on what you propose to do with this.

A little more information would help.
Hi Sir Trews.
I forgot that this particular batch file looks a little suss....
I am creating a file shredding program, and this batch is part of one of the
processes involved in the shredding.

The program I am making allows the user to kill a file E.g: malware, that has a process running in the background using the file.
It also allows the user to take ownership over chosen files, and take permissions for files.
Also allows the user to search the running processes to see what running processes are using services.

The log i want created, will be read by my program, and displayed in the program window.

I hope I have given you enough info to convince you this is for good intentions
pure_evil020 is offline   Reply With Quote
Old 04-08-2009   #4
Senior Security Analyst
 
chiaz's Avatar
 
Join Date: Jun 2006
Location: Singapore
Posts: 5,176
PC Experience: PC Guru
Default Re: exporting results from batch file

Hello.

I recall this page being recommended on another forum for learning Windows batch file scripting, it may or may not be useful to you...
Rob van der Woude's Scripting Pages
chiaz is offline   Reply With Quote
Old 04-08-2009   #5
Bronze Member
 
Join Date: Apr 2009
Posts: 3
PC Experience: Experienced
Default Re: exporting results from batch file

here is what i've put together so far:

if exist test (del test & echo. test deleted > log.txt) & exit
else
if exist test (del test & echo. test deleted > log.txt) & exit
else
(echo. Failure! "test" does not seem to exist, or cannot be deleted. >> log.txt)
I'm still having a problem with this though...
It is creating two seperate log files. one from the first line, and one from the second.

anyone know why its doing this?
pure_evil020 is offline   Reply With Quote
Old 06-07-2009   #6
Tech Member
 
LPChip's Avatar
 
Join Date: Mar 2009
Posts: 196
PC Experience: PC Guru
Default Re: exporting results from batch file

Sorry for the huge delay.

The reason why this is happening, is because a batchfile that uses ()'s is being executed in a delay. First the main statements are processed then the ones in the brackets. Basically it doesn't detect that the file is gone and thus processes it twice.
__________________
Specialised in programming(PHP, VBA, mySQL, HTML, CSS, BAT) and windows XP and earlier
Do you possibly have spyware? Try doing some prework
LPChip is offline   Reply With Quote
Old 08-24-2009   #7
Tech Support Team
 
samuria's Avatar
 
Join Date: Aug 2009
Posts: 625
PC Experience: PC Guru
Default Re: exporting results from batch file

instead of > log.txt put >> log.txt to append to the file better still get Autoit from AutoIt Script Home Page its a lot simpler and very simple to use
samuria is offline   Reply With Quote

Reply


Bookmarks

Tags
batch, exporting, file, results
Similar discussions...
Thread Thread Starter Forum Replies Last Post
Batch File Delay ? andy15star Programming 6 04-09-2009 06:12 PM
File sorting with DOS batch file (XP) Bowzerbro Programming 5 04-04-2009 11:13 PM
Help With Batch File dc_1988 Windows XP/2000 1 12-24-2007 09:26 PM
[Resolved] Batch File/Script Shazada Windows XP/2000 4 06-20-2007 02:51 AM
need help with batch file gils0n Unfinished Threads 5 12-07-2006 05:17 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On




All times are GMT. The time now is 10:20 PM.
Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2