none
Need help with existing Batch script RRS feed

  • Question

  • Hi folks, 

    I am trying to create a Batch file that will start a Performance Monitor utility 'data collector', let it run, then find the latest .html report file it creates in the following directory:  C:\PerfLogs\Admin\BenchmarkSystemPerformance

    My the problem is whenever a new performance data collection starts it creates a NEW folder and by default it is not accessible until you first accept the Prompt: "You currently don't have permission to access this folder.   Click continue to permanently get access to this folder."   Must be design by Microsoft with 'system' only having access I think. 

    I think I need to add a line in the logic to change the folder it finds to search for the latest .html file and change it's Security permissions.   Would like to first change the latest created folder in the directory to have the Everyone group added with Full Permissions BEFORE it continues to Open the latest .html file found.   Something like   icacls "c:\folder" /remove:d /grant:r Everyone:(OI)(CI)F /T added to it, just don't know where to put it

    This is what I have so far: 

    Start logman start benchmark
    Timeout.exe 200
    SET "SearchPath=C:\PerfLogs\Admin\BenchmarkSystemPerformance"
    SET "FilenameFilter=*.html"
    for %%r in ("%SearchPath%\.") do for /f "tokens=3,*" %%a in ('
        robocopy "%%~fr." "%%~fr." "%FilenameFilter%" /l /nocopy /s /is /njh /njs /ndl /nc /ns /ts
        ^| sort /r
        ^| findstr /n "^"
        ^| findstr /l /b /c:"1:"
    ')
    do explorer %%b

    *NOTE: if I  first give access to the new folder created by the Performance Monitor utility by Microsoft it does search and open up the latest HTML report.   By just running the following: 

    SET "SearchPath=C:\PerfLogs\Admin\BenchmarkSystemPerformance"
    SET "FilenameFilter=*.html"
    for %%r in ("%SearchPath%\.") do for /f "tokens=3,*" %%a in ('
        robocopy "%%~fr." "%%~fr." "%FilenameFilter%" /l /nocopy /s /is /njh /njs /ndl /nc /ns /ts
        ^| sort /r
        ^| findstr /n "^"
        ^| findstr /l /b /c:"1:"
    ')
    do explorer %%b

    Appreciate any help - trying to automate benchmarking a little 






    • Edited by JeremyM1978 Tuesday, February 5, 2019 12:12 AM
    • Moved by Bill_Stewart Friday, March 15, 2019 7:05 PM This is not "fix/debug/rewrite my script for me" forum
    Tuesday, February 5, 2019 12:07 AM

All replies

  • That's not a scripting issue. It's an issue with the granted rights on the parent folder.

    Even it does not belong here: Place the account you use to access this folder or to run your scripts not directly into the group with access right to this folder - place it in a subgroup.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, February 5, 2019 1:15 AM
  • No one should be using batch scripts anymore.  They are obsolete and only maintained for backward compatibility.


    \_(ツ)_/

    Tuesday, February 5, 2019 1:23 AM