so i’m trying to figure this out and i don’t think my scripting skills are up to par. 🙁
basically what i’m trying to do is this.
have a script call a file, the file has a list of members servers that i want to look through. i want to search for a file on each one of those servers and then spit out a log that lists that file’s path.
so.. for example the file that is to be referenced is text.txt and within that file lists server 1, 2, 3.
i want to scan each server in this path c:\temp\ all sub dirs and look for file.exe
then spit out a log that displays the server and its path location of file.exe
server1 c:\temp\dir1\file.exe
server2 c:\temp\dir3\dir5\file.exe
anybody??? 🙁
thanks in advance!
this is what i’ve done so far…
@ECHO OFF
SET FLNM=file.exe
SET DRV=c
SET DIRS=temp
IF NOT DEFINED FLNM GOTO NAME
IF /I "%FLNM%"=="/Q" GOTO :EOF
SET FLNM=%FLNM: =.%
:DV
IF NOT DEFINED DRV GOTO DV
IF EXIST RESULTS.TXT DEL RESULTS.TXT
IF DEFINED DIRS SET DIRS=%DIRS: =.%
FOR %%D IN (%DRV%) DO (
FOR %%G IN (%FLNM%) DO (
IF DEFINED DIRS (
FOR %%C IN (%DIRS%) DO (
DIR %%D:\ /L /B /S|FINDSTR /I /E \%%C.\%%G>>RESULTS.TXT
)
) ELSE (
DIR %%D:\ /L /B /S|FINDSTR /I /E \%%G>>RESULTS.TXT
)
)
)
CALL :ZEROBYTE RESULTS.TXT
IF NOT EXIST RESULTS.TXT ECHO:"FILES NOT FOUND">>RESULTS.TXT
START NOTEPAD RESULTS.TXT
EXIT /B
:ZEROBYTE
IF %~Z1==0 DEL RESULTS.TXT
GOTO :EOF
i can get this to run locally on each but i rather run it centrally. also i can’t seem to get it to look under all the directories. if i list a directory, it only scans within that root only.
If
test.txtis formatted like this:then you could do this:
Note that you need to be a domain administrator to do this for remote Windows Vista/7/Server 2008/R2 computers, but for Windows 2000/XP/Server 2003 you only need to have local administrator rights to each PC.
Alternatively you could share the temp folder on each PC e.g. using
net share temp$=C:\tempand then you could use\\%s\temp$\file.exeinstead, then you would only need normal share and file permissions.