|I have revised the syntax that you suggest, but non of them work.|
The script below only work on C drive for sure it will open docx once it found it that file exist in C drive.
The key point is how can I correct the script below, because I want to run this batch file for search my document it might located in M, N, L and O drives. If it found that document exist in there then it should auto open the document immediately. it works only on C drive that I tested before. If possible make it work on other drive then my life get easier.
Your great support is greatly appreciated Thanks all of you help again,
set "Word=C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE"
SET /P CTOID=Enter CTO file name:
FOR /F %%a IN ('MOUNTVOL^|FINDSTR [A-Z]:\\') do (
FOR /F "tokens=*" %%b in ('DIR /B /S "%%a%CTOID%" 2^>nul') do (
SET "CTOID=%%b" & GOTO FOUND
ECHO ERROR: File not found.
ECHO File found in "%CTOID%".
"C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" "%CTOID%"