Batch Help: [for In Do] Agh!

Discussion in 'Web Design & Coding' started by chaos945, Mar 4, 2004.

  1. chaos945

    chaos945 Moderator

    Messages:
    934
    I'm trying to get this script to find the location of SPYBOTSD.exe on all available drives and then run it. Any suggestions would be helpfull!

    Successfully I've gotten the script to search specified drives for the string spybot then output the findings, but I can't actually use the output as a variable. Also I've been experimenting with the FOR command but no luck as of yet.

    /EDIT
    I could actually get the script to find spybotsd.exe exactly and output the line number, but how would I tell the program to run it at that line?

    Code:
    @ECHO OFF
    IF EXIST *OUT.TXT DEL *OUT.TXT
    TREE /F c:>[C]OUT.TXT
    TREE /F g:>[G]OUT.TXT
    FIND /I /N "SPYBOT" [C]OUT.TXT
    FIND /I /N "SPYBOT" [G]OUT.TXT
    IF EXIST *OUT.TXT DEL *OUT.TXT
    ECHO.
    ECHO.
    ECHO %ERRORLEVEL% ERRORS DURING PROCESS
    PAUSE
     
  2. chaos945

    chaos945 Moderator

    Messages:
    934
    I was so close then M$ snatched it away, using a 3rd party command "LOCATE" I was able to get the script to successfully find SPYBOTSD.exe then create a file based on the location found, and based on the command I associated with it "PATH" in this case.

    In theory, it was supposed to update the PATH's list to include the new location found but unfortunately, it didn't! Why? I don't know...probably because the PATH was specified inside the CALL procedure of another running script or something like that. Another idea I had was to try to APPEND the procedure "START SPYBOTSD.exe" to the end of the generated file...but no such luck using the default available files.

    /EDIT
    BTW, I did manage to get the script to actually find SPYBOTSD.exe then run it every single time successfully, the problem is I can't use switches doing it this way making it completly useless for my purposes!!! To do it this way add "START" instead of "PATH".

    CODE TO RUN FIND SPYBOTSD.EXE THEN RUN IT AUTOMATICALLY:
    Code:
    @ECHO OFF
    DEL %TMP%\*.* /q
    DEL %TEMP%\*.* /q
    CLS
    IF EXIST *START.BAT DEL *START.BAT
    PATH FILES;%SYSTEMROOT%\System32\Wbem\
    LOCATE SPYBOTSD.EXE /F:1 /B:"start">SPYBOT_START.BAT
    CALL SPYBOT_START.BAT
    IF EXIST *START.BAT DEL *START.BAT
    ECHO.
    ECHO %ERRORLEVEL% ERRORS DURING PROCESS
    PAUSE
    ATTEMPTED CODE TO FIND SPYBOTSD.EXE THEN RUN IT AUTOMATICALLY WITH SWITCHES
    Code:
    @ECHO OFF
    DEL %TMP%\*.* /q
    DEL %TEMP%\*.* /q
    CLS
    IF EXIST *START.BAT DEL *START.BAT
    PATH FILES;%SYSTEMROOT%\System32\Wbem\
    LOCATE SPYBOTSD.EXE /F:1 /B:"PATH">SPYBOT_START.BAT
    CALL SPYBOT_START.BAT
    SPYBOTSD.EXE /autoupdate /autoimmunize /autocheck /autofix /autoclose
    IF EXIST *START.BAT DEL *START.BAT
    ECHO.
    ECHO %ERRORLEVEL% ERRORS DURING PROCESS
    PAUSE
     
  3. yoyo

    yoyo _________________

    Messages:
    1,557
    Can you use this one? It retrieves the application path from the registry.
    (That's just one line.)

    for /f "usebackq skip=4 tokens=6,7*" %%a in (`reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Spybot - Search & Destroy_is1" /v "Inno Setup: App Path"`) do "%%a %%b %%c\spybotsd.exe" /autocheck

    Does spybot close automatically if you additionally use the /autofix switch? Otherwise you would have to use the start command for the batch to continue. (start "spybot" /b ...)

    Edit: Just saw there is an /autoclose switch ..
     
  4. chaos945

    chaos945 Moderator

    Messages:
    934
    OMG, one line. Where were you a day ago? :D