[Jo...] Posted February 14 Share Posted February 14 Hi everyone, On the topic of batch files, I saw another post on this today. I didn't want to hijack that topic so I figured I would start a new one. My company has been using the report end batch for years (before my time). This file essentially moves all the reports/excel/text files to the network. When this Batch file runs now it takes 3-5 minutes to complete the full execution. At this time Calypso is completely locked up until completion. I imagine that this is due to the size/number of files it needs to move in our case. This is the essential complaint our operators are telling me about. Has anyone run into this? Is this expected? Are there any alternatives that run more fluently with Calypso? I know there is a section in Calypso to edit the location "name for output files" under the resource drop-down. I have used this at my last company, but I do not dare mess with the batch file until I fully vet out other options. TIA! Link to comment Share on other sites More sharing options...
[Mi...] Posted February 14 Share Posted February 14 I'm not extremely well versed in this, but post the code from the batch file. Without knowing what it's doing I don't see a lot of help available. You may want to hide the file paths depending on how sensitive that is. I have a batch file that moves the results and it happens so fast nobody would ever notice, but I'm only testing for network connectivity, then quickly copying table files. I hadn't considered Calypso might be waiting for this file to execute... Link to comment Share on other sites More sharing options...
[Ro...] Posted February 17 Share Posted February 17 I had a bunch of programs, heavy with profile measurements, free form with thousands of points, and my programs would lock up for a couple minutes at the end of each run. The fix was to have IT come out and install lots of new memory. I can't remember how much but it was a lot. Programs ran fine after that. Link to comment Share on other sites More sharing options...
[DW...] Posted February 17 Share Posted February 17 Please sign in to view this quote. Batch is old school, with less functionality than say PowerShell... is the script only copying files from one location to another? Is it copying ALL the files each time, or does it compare the sourceDirectory to the outputDirectory and only copy the difference? You could still use your reportend batch file to fire a PowerShell script that does essentially the same action, but frees up Calypso in the meantime. Link to comment Share on other sites More sharing options...
[Jo...] Posted February 17 Author Share Posted February 17 Morning gents, Here is a copy of the batch file text. From my understanding, this file was originally created from Zeiss and updated by previous programmers as well as IT. It looks like there is a little reiteration that might be able to be consolidated. Please sign in to view this username. this could be a plausible issue, as some of our programs are complex with curve/freeform. This still has a delay when running simpler programs too, which I would believe to be network-related. I do like the idea of PowerShell not bogging down Calypso, you mentioned DWC. I may have to look into this. Please sign in to view this quote. Link to comment Share on other sites More sharing options...
[DW...] Posted February 17 Share Posted February 17 (edited) Please sign in to view this username. Have your batch file fire a PowerShell script. It has the same functionality as the batch file, but will free up Calypso immediately. Here’s a PowerShell script that replicates the functionality of your batch file: # Terminate any running instances of Excel Stop-Process -Name "excel" -Force -ErrorAction SilentlyContinue # Define paths $sourceCycleTimePath = "C:\Zeiss\CycleTime\*.*" $destinationCycleTimePath = "L:\10_SYR_CMM_Reports\CMM Cycle Times\CycleTimeCMM3\*.*" # Check if destination directory is empty if (Test-Path $destinationCycleTimePath) { # Change CMM number Copy-Item -Path $sourceCycleTimePath -Destination "L:\10_SYR_CMM_Reports\CMM Cycle Times\CycleTimeCMM3\" -ErrorAction Stop # Delete files from source Remove-Item -Path $sourceCycleTimePath -Force } # Delete .ps files Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.ps" -Force # Delete extra files Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*._chr.txt" -Force Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*._hdr.txt" -Force Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*._fet.txt" -Force Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.tmp*.pdf" -Force # Check if destination exists for Point Files $pointFilesDestination = "L:\10_SYR_CMM_Point_Files\Zeiss\*.*" if (Test-Path $pointFilesDestination) { # Copy .txt files to L Drive Copy-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.txt" -Destination "L:\10_SYR_CMM_Point_Files\Zeiss\" -ErrorAction Stop # Delete .txt files from source Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.txt" -Force } # Check if destination exists for XLS files $xlsDestination = "L:\10_SYR_CMM_Reports\XLS\*.*" if (Test-Path $xlsDestination) { Copy-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.xls" -Destination "L:\10_SYR_CMM_Reports\XLS\" -ErrorAction Stop # Delete .xls files from source Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.xls" -Force } # Check if destination exists for PDF files $pdfDestination = "L:\10_SYR_CMM_Reports\PDF\*.*" if (Test-Path $pdfDestination) { Copy-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.pdf" -Destination "L:\10_SYR_CMM_Reports\PDF\" -ErrorAction Stop # Delete .pdf files from source Remove-Item -Path "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\*.pdf" -Force } Here is a more concise and logical version of the PowerShell script: # Terminate any running instances of Excel Stop-Process -Name "excel" -Force -ErrorAction SilentlyContinue # Define paths $sourceCycleTimePath = "C:\Zeiss\CycleTime\*.*" $destinationCycleTimePath = "L:\10_SYR_CMM_Reports\CMM Cycle Times\CycleTimeCMM3\" $resultsPath = "C:\Program Files (x86)\Zeiss\Calypso\home\om\workarea\results\" $pointFilesDestination = "L:\10_SYR_CMM_Point_Files\Zeiss\" $xlsDestination = "L:\10_SYR_CMM_Reports\XLS\" $pdfDestination = "L:\10_SYR_CMM_Reports\PDF\" # Function to copy and remove items function CopyAndRemove($source, $destination) { if (Test-Path $destination) { try { Copy-Item -Path $source -Destination $destination -ErrorAction Stop Remove-Item -Path $source -Force -ErrorAction Stop } catch { Write-Host "Error during copy or remove: $_" } } } # Check if destination directory is empty and copy files if (-not (Get-ChildItem -Path $destinationCycleTimePath -ErrorAction SilentlyContinue)) { Copy-Item -Path $sourceCycleTimePath -Destination $destinationCycleTimePath -ErrorAction Stop Remove-Item -Path $sourceCycleTimePath -Force } # Delete specific file types $fileTypesToDelete = @("*.ps", "*._chr.txt", "*._hdr.txt", "*._fet.txt", "*.tmp*.pdf") foreach ($fileType in $fileTypesToDelete) { Remove-Item -Path "$resultsPath$fileType" -Force -ErrorAction SilentlyContinue } # Copy and remove point files CopyAndRemove "$resultsPath*.txt" $pointFilesDestination CopyAndRemove "$resultsPath*.xls" $xlsDestination CopyAndRemove "$resultsPath*.pdf" $pdfDestination Basically your batch file starts by closing all instances of Excel, going to the standard locations for results and deletes out the files it doesn't want to copy, goes to another destination and does copy the text files, then deletes those, and finally copies and deletes some PDFs. You'll probably need to run PowerShell ISE as administrator to test.. or give the script to IT and have them vet it. Edited February 17 Link to comment Share on other sites More sharing options...
[Jo...] Posted February 17 Author Share Posted February 17 Wow you rock Please sign in to view this username. thanks for the help! I will run this by our IT and then see if we can test it. I will let you guys know how I make out. Link to comment Share on other sites More sharing options...
[Jo...] Posted February 24 Author Share Posted February 24 Update! So I did some testing and got it to work. Since the Batch file needed to execute through the command prompt, it did not eliminate the delay entirely. There was a big improvement in the lockup time though. I did use the "Concise and logical" Version of DWCs code. One program that took roughly 2 minutes to transfer got shortened to roughly 30 seconds. The second program I tested, had an original lockup time of 6 minutes, this got shortened to 1.5 minutes. A huge improvement on both examples. In order to execute the PowerShell file I used the below code within the "Report_End.Bat". Powershell.exe -executionpolicy remotesigned -File "C:\Users\Public\Documents\Zeiss\CALYPSO\workarea\inspections\PowerShell Report End.ps1" I have integrated this for full use today. Hopefully, no issues arise. Thanks again for the help gents! Link to comment Share on other sites More sharing options...
[DW...] Posted February 25 Share Posted February 25 Please sign in to view this quote. Please sign in to view this username. Glad to see it helped! Try changing your batch file to - @echo off start /B powershell -ExecutionPolicy Bypass -File "C:\Users\Public\Documents\Zeiss\CALYPSO\workarea\inspections\PowerShell Report End.ps1" or - @echo off powershell -NoProfile -ExecutionPolicy Bypass -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File C:\Users\Public\Documents\Zeiss\CALYPSO\workarea\inspections\PowerShell Report End.ps1'" This should free up the batch file by creating a new instance of PowerShell. Let me know if this quickens things up a bit! Also, I am curious what your IT and coworkers had to say when you showed them what it does.. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in