| 1. |
Solve : How to find automatically the path for an appli ?? |
|
Answer» Hi all! That works well, but what if it's not installed here ? To scan the whole disk is the only solution ?i am afraid so. you can try the vbscript posted, or do the same with batch Code: [Select]dir /B /S /A-D | findstr /I "yourfilename.ext" You search like that? An alternative would be (in a batch file): Code: [Select]for /f %%I in ('dir "C:\file.txt" /s /b') do echo %%IYou can just use one % if you do it directly from Command Prompt. If you want to just find the path (not to DISPLAY the filename), do this: Code: [Select]for /f %%Iin ('dir "C:\file.txt" /s /b') do echo %%~dpIQuote from: Dark Blade on June 18, 2007, 05:27:30 PM You search like that?yes, that's my way of doing it when i have more search requirements that can't be accomplished just by cmd.exe's wildcard globbing.Okay, thanks! for /f %%I in ('dir "C:\testasgi.txt" /s /b /p') do echo %%~dpI I'm near the solution, now. I still have a problem with spaces. If the program is installed in "Program Files", the echo %%I display only "C:\Program" which is not very nice, at least from my point of VIEW... Any idea ?Quote from: rekam on June 19, 2007, 01:47:03 AM I'm near the solution, now. I still have a problem with spaces. If the program is installed in "Program Files", the echo %%I display only "C:\Program" which is not very nice, at least from my point of view... You need to set a DELIMS switch appropriately to avoid the FOR command halting at the first space. like this for /f "delims==" %%I in ('dir "C:\testasgi.txt" /s /b /p') do echo %%~dpI Type FOR /? at the prompt for more information. Also, do you REALLY need the /p switch with DIR? This does not always work well in batch files. I can't see what use it is, unless it's left over from debugging. You're trying to find one file, right? You're never going to have a screenful of information. |
|