views:

26

answers:

1

Can anyone improve on this? Requires Sysinternals Strings

date /T >N:\output.txt
net use z: /delete
net use z: \\svr-002\rmstudentwork
@cd /d "z:\"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.xls | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.ppt | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.doc | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.xlsx | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.pptx | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.docx | findstr \.swf >> "N:\output.txt"

date /T >>N:\output.txt
net use z: /delete /yes >>N:\output.txt
net use z: \\svr-003\rmstudentwork
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.xls | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.ppt | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.doc | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.xlsx | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.pptx | findstr \.swf >> "N:\output.txt"
"N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe" -s *.docx | findstr \.swf >> "N:\output.txt"
net use z: /delete /yes

Basically it mounts a share as a network drive then runs through the share looking for swf files inside office documents.

+1  A: 

I'm not a batch file expert, but I think you could:

  • Store repeated paths in variables:

    set STRINGS="N:\Scripts and Reg Frags\FindEmbededFlashFiles\strings.exe"
    set OUTFILE=N:\output.txt
    
  • Replace repeated commands with a FOR loop, e.g.:

    for /r z:\ %%f in (*.xls *.ppt *.doc *.xlsx *.pptx *.docx) do (
      %STRINGS% -q "%%f" | findstr \.swf >> %OUTFILE%
    )
    

    (Note that this loop also replaces @cd /d "z:\" and the -s parameter of strings.exe.)

Disclaimer: I'm writing this off the top of my head, so the suggested code may not work or may need additional fine-tuning. Anyway, I hope this will give you the idea.

Helen