I would like to search for a missing windows file on the pc...
then depending on the result store the result in 2 of 3 files along with the computer name..
The process is;
search for file MSCOMC2.OCX...
store date and time of search and computer name and "File Found"(or "Not Found") result in a file called search.txt
and if the file was found store the same information in Filefound.txt
and if the file was not found store the same information in FileNotFound.txt
I would like to sepearte the results by commas in the text file... and I need to be able or the results to append to as many searches will be performed.
What I have so far is(not much);
echo %computername% >> results.txt
cd c:\
dir "MSCOMCT2.OCX" /s >> \\glkas0676\tm1data\results.txt REM BUT THIS GIVES ME THE COMPLETE RESULT NOT THE FOUND OR NOT FOUND.
Simon
Help! Help! - Simple search and store results in 1 of 3 file
Moderator: DosItHelp
Re: Help! Help! - Simple search and store results in 1 of 3 file
smehnert
To append the different results to the same line is IMHO not a good idea, because batch can't handle strings >1024 characters.
Figure out if this code would work for you.
Regards
aGerman
To append the different results to the same line is IMHO not a good idea, because batch can't handle strings >1024 characters.
Figure out if this code would work for you.
Code: Select all
@echo off &setlocal
set "outfile=results.txt"
pushd "C:\"
for /f "delims=" %%a in ('dir /a-d /b /s "MSCOMCT2.OCX"') do set "fileName=%%a"
popd
if not defined fileName (
>>"%outfile%" echo %date% %time:~,8%,%computername%,file "MSCOMCT2.OCX" not found
) else (
>>"%outfile%" echo %date% %time:~,8%,%computername%,file "%fileName%" found
)
Regards
aGerman
Re: Help! Help! - Simple search and store results in 1 of 3 file
Agerman you are a star, thankyou very much.
SMehnert
SMehnert