Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Dell Precision 360

Original Message
Name: WkEndHacker
Date: March 19, 2008 at 12:21:47 Pacific
Subject: Dell Precision 360
OS: XP Pro SP2
CPU/Ram: 3GB RAM
Model/Manufacturer: Dell Precision 360
Comment:
With help from a few of you, I was able to write a Batch file that created folders for output files and moved folders and files to a mapped drive. I also borrowed/wrote a simple VB script and pasted it into my CAM database link table so that when I output files from a design program it starts up the batch file.

Only problem now is that since the CAD/CAM program uses two of the links in that table, now I get two instances of the batch file running...

Is there a way to write the batch file to check for a prior instance of it running?


Report Offensive Message For Removal


Response Number 1
Name: IVO
Date: March 19, 2008 at 13:31:58 Pacific
Subject: Dell Precision 360
Reply: (edit)
The straightforward way is to code at the beginning of your batch

@echo off
if exist "%temp%\%~n0.run" exit
type Nul > "%temp%\%~n0.run"

and just before it ends

del "%temp%\%~n0.run"

That sets a flag file in your temp folder named Your_Batch.run that acts as a semaphore. Beware that if the batch fails you have to delete manually the flag file.


Report Offensive Follow Up For Removal

Response Number 2
Name: WkEndHacker
Date: March 19, 2008 at 14:13:39 Pacific
Subject: Dell Precision 360
Reply: (edit)
Since the batch file creates the folders in the same directory each time, couldn't I create this run file in that directory?

That way I wouldn't have to create a shortcut to the temp folder for the non-techies.


Report Offensive Follow Up For Removal

Response Number 3
Name: WkEndHacker
Date: March 19, 2008 at 14:22:08 Pacific
Subject: Dell Precision 360
Reply: (edit)
Oh yeah. That works. But then I'm not sure I like this. Possibly the designer could exit the batch file on purpose, without letting it delete the temp file. Perhaps I need to put the delete/exit farther up the batch file rather than the end.

Thanks for the help.


Report Offensive Follow Up For Removal

Response Number 4
Name: IVO
Date: March 19, 2008 at 14:25:40 Pacific
Subject: Dell Precision 360
Reply: (edit)
Yes, just be sure the flag file is created in the same folder whatever the origin of the batch is otherwise its purpose vanishes.

I selected %temp% becouse that folder satisfies the above constraint, but your solution is right as far as the previous statement is true.


Report Offensive Follow Up For Removal

Response Number 5
Name: WkEndHacker
Date: March 19, 2008 at 14:32:02 Pacific
Subject: Dell Precision 360
Reply: (edit)
Ok. That works. I put the delete command farther up the batch file so that it deletes the temp file after the user has to input the user and job name, but before the folders are created and files moved. This gives the second script time to initiate the second batch file, which finds the temp file, and exits.

Here's another question.

If the user exits or Ctrl C out of the batch file, is it possible for the batch file to delete all the folders and files still in the output directory?

I'm assuming I can use a similar command to what you used:

If exist "C:\CNCRun\*.txt" del "C:\CNCRun\*.txt"

No.. that wouldn't work, because the user exits before that command could run...

Hmmmmm....


Report Offensive Follow Up For Removal


Response Number 6
Name: IVO
Date: March 19, 2008 at 14:45:11 Pacific
Subject: Dell Precision 360
Reply: (edit)
About your question on Ctrl-C the answer is NO as you can't control the abend process once it atarts, just you can forbid that.

Why not test for existence of folders/files debris at starting and delete them, i.e.

@echo off
if exist "%temp%\%~n0.run" exit
type Nul > "%temp%\%~n0.run"
If exist "C:\CNCRun\*.txt" del "C:\CNCRun\*.txt"

About checking for batch running more sophisticated methods exist if it is worth of it.


Report Offensive Follow Up For Removal

Response Number 7
Name: WkEndHacker
Date: March 19, 2008 at 15:29:48 Pacific
Subject: Dell Precision 360
Reply: (edit)
I thought the deletion of files might work. But then I realized that I'd be deleting all the legitimate files I just output as this is the output folder for each local machine prior to moving them to the network folder.

The run numbers of these output files are always consecutive, so I suppose I could check the run numbers and only delete the earlier ones. But I've not been able to think through that logic being unfamiliar with the batch commands.

I'd also want to exclude from deletion, two permanently existing folders (named Cowboy and CNCParser) in the "C:\CNCOut" folder.

The file naming is as follows:
CncRun77.txt
R7701001.txt
R7701002.txt
R7705001.txt
R7705002.txt
R7705003.txt

The first file contains comma separated information about the job, and the numbers in the file name denote the run number.
The next set of files contain program code to run the CNC machine. The run numbers are the 2nd and 3rd digits in the name, and the material run numbers are denoted by that last four numbers (1001-2 and 5001-3 etc.)

So assuming I ouput the same job again, the run numbers would jump up to 78 (or higher, depending on whether someone output on another workstation):

CncRun78.txt
R7801001.txt
R7801002.txt
R7805001.txt
R7805002.txt
R7805003.txt


Report Offensive Follow Up For Removal

Response Number 8
Name: IVO
Date: March 19, 2008 at 15:47:26 Pacific
Subject: Dell Precision 360
Reply: (edit)
Hi WkEndHacker,

I think I can help you to set up your script system supporting CAD/CAM, but I stay in Italy and now here time is late night, more tomorrow I get a busy day at customer's company. So please specify better the deletion logic of files as from your previous post that is not fully clear to me and tomorow or Friday I'll try to find a solution.

Contact me by e-mail if you want using the Computing.net messaging system.

Sorry but now I have to leave...


Report Offensive Follow Up For Removal

Response Number 9
Name: Razor2.3
Date: March 19, 2008 at 17:54:58 Pacific
Subject: Dell Precision 360
Reply: (edit)
Wow, I'd probably just employ TASKLIST, or attempt something similar.

Report Offensive Follow Up For Removal

Response Number 10
Name: WkEndHacker
Date: March 20, 2008 at 06:28:29 Pacific
Subject: Dell Precision 360
Reply: (edit)
Tasklist eh? I'll look into it.. thanks Razor.

The files to be deleted would be all previous run numbers. In this case it would be all files with run numbers of 77 and previous.


Report Offensive Follow Up For Removal

Response Number 11
Name: WkEndHacker
Date: March 20, 2008 at 06:41:40 Pacific
Subject: Dell Precision 360
Reply: (edit)
Razor,
What exactly would you use Tasklist to do? I'm looking at the help file now, but of course my peabrain won't take it in very well unless I see an example and an explanation. I'm imagining using it with the filter switch.... but that still would only display certain items...

Report Offensive Follow Up For Removal

Response Number 12
Name: IVO
Date: March 21, 2008 at 01:48:22 Pacific
Subject: Dell Precision 360
Reply: (edit)
I doubt TaskList may detect easily the in fly batch because all batch scripts are associated to cmd.exe so you have to know the exact process ID to identify your target.

However I use similar tools and I don't know exactly TaskList's output.


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Dell Precision 360

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




XP Installed to G?

exessive internet traffic

ZoneAlarm Question. Blocked Connect

Windows Live Messenger Problem

Delete $Uninstall after SP3 updates


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC