Note that there are some explanatory texts on larger screens.

plurals
  1. POMS-DOS Batch: Non-Recursive File Searching in a Directory
    text
    copied!<p>My goal is to search in ANY directory in the C:\ drive--but not the directories of those directories--for a file named "setup95.exe". If the file exists, then I need to write the path to a variable called <code>%getpath%</code>. </p> <p>I was originally trying to simply use <code>dir</code> but it doesn't meet my expectations. I need to get ANY directory in C:\ and search through it. As an exemplar, say I there is a folder in C:\ called <code>__neverhood</code>. Within that folder, there is a file named <code>setup95.exe</code>. The program doesn't know what folder it is it. It only knows it is in C:\, so it needs to search through each directory in C:\ to find <code>setup95.exe</code>.</p> <p>UPDATE: New code. It finds the file, but it's no good for the disk drive. Here's an excerpt of the code:</p> <pre><code>@ECHO OFF SETLOCAL SET "traversity=C:\Program Files (x86)\" if not exist "C:\Program Files (x86)" SET "traversity=C:\Program Files\" SET intricacy=%traversity%The Neverhood Restoration Project SET obscurity=%traversity%DreamWorks Interactive SET psychedelia=%obscurity%\Neverhood SET abstraction=WAVistaWin7.exe :removenrp if exist "%traversity%The Neverhood Restoration Project Julia\unins000.exe" ( "%traversity%The Neverhood Restoration Project Julia\unins000.exe" ) :delreg if %PROCESSOR_ARCHITECTURE%==x86 ( reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\DreamWorks Interactive" /f ) else ( if %PROCESSOR_ARCHITECTURE%==AMD64 ( reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\DreamWorks Interactive" /f ) else ( reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\DreamWorks Interactive" /f )) if exist "%obscurity%" echo y | rmdir /S /Q "%obscurity%" mkdir "%obscurity%" mkdir "%psychedelia%" copy /Y "%~dp0%abstraction%" "%psychedelia%" for /d %%a in (c:\*) do for /f "delims=" %%i in ('dir /b /a-d "%%~a\setup95.exe" 2^&gt;nul') do set "getpath=%%~a" if defined getpath (echo path is %getpath%) else rem ok if exist "%getpath%setup95.exe" ( echo MSGBOX "Pyroneous did not distribute the Neverhood illicitly to you. Remember that the only legal way to run the Neverhood is to buy it. We will still permit you to install the Neverhood, but we are not responsible for your actions. You can read our full purposes at theneverhood.sourceforge.net. Thanks!" &gt; %temp%\TEMPmessage.vbs call %temp%\TEMPmessage.vbs del %temp%\TEMPmessage.vbs /f /q reg import "%~dp0neverhood.reg" START "%getpath%setup95.exe" ) else ( for %%D in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do vol %%D: &gt;output 2&gt;output &amp;&amp; if exist %%D:\setup95.exe set DRIVE=%%D if not defined DRIVE echo It appears you don't have the Neverhood on your computer. Please check http://theneverhood.sourceforge.net/setup/ for more information. &amp;&amp; pause if exist "%DRIVE%:\setup95.exe" ( echo MSGBOX "Hey. Thank you for purchasing the Neverhood. That is, if you're not using an burned ISO/exploitation." &gt; %temp%\TEMPmessage.vbs call %temp%\TEMPmessage.vbs del %temp%\TEMPmessage.vbs /f /q reg import "%~dp0neverhood.reg" START D:\setup95.exe </code></pre> <p>) )</p> <p>The output returns this: </p> <pre><code>C:\Users\b\Desktop\somnacea\files\thankyousanta\necessity&gt;install.bat ERROR: The system was unable to find the specified registry key or value. The process tried to write to a nonexistent pipe. 1 file(s) copied. The process cannot access the file because it is being used by another process. The process cannot access the file because it is being used by another process. It appears you don't have the Neverhood on your computer. Please check http://th eneverhood.sourceforge.net/setup/ for more information. Press any key to continue . . . </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload