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?
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.
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.
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...
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):
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.
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...
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.
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