Improve simple Batch Script
by darkhorse10123 - Saturday January 18, 2025 at 04:30 AM
#1
Hi everyone,
I’ve been working on a batch script to automate Google searches based on a list of terms from a file (
inputs.txt
). Here’s what it does:
  1. Reads search terms line by line from
    inputs.txt
    .
  2. Opens each search term in an incognito browser tab (Microsoft Edge in this case).
  3. Pauses after every 10 tabs to prevent overloading the browser.
Here’s the current code:

===============================================
===============================================
===============================================
===============================================
===============================================
===============================================
@Echo off
setlocal EnableDelayedExpansion

REM Input file containing search terms
set input_file=inputs.txt

REM Check if the input file exists, and prompt the user to create it if not
if not exist "%input_file%" (
    echo ERROR101: 'inputs.txt' not found. Please create the file, add your search terms, and try again.
    pause
    exit
)

REM Initialize the tab counter
set /a num_tabs=0

REM Count the total number of lines in the input file
for /f %%c in ('find /c /v "" %input_file%') do set total_tabs=%%c

REM Process each line in the input file
for /f %%a in (%input_file%) do (
    REM Open the search query in an incognito browser tab
    start msedge --inprivate "https://www.google.com/search?q=%%a"
   
    REM Increment the tab counter
    set /a num_tabs+=1

    REM Pause after every 10 tabs to prevent overloading the browser
    if !num_tabs! geq 10 (
        echo Pausing to prevent overload. Press any key to continue...
        pause
        set /a num_tabs=0
    )
)

echo All searches completed. Total tabs opened: %total_tabs%.
pause
===============================================
===============================================
===============================================
===============================================
===============================================
===============================================

What I’d Like to Improve:
  1. Error Handling: How can I make the script more robust if
    inputs.txt
    has invalid lines or the browser doesn’t respond?
  2. Flexibility: Can I make the browser configurable (e.g., allow switching to Chrome or Firefox)?
  3. Performance: Are there ways to make it faster without risking browser or system overload?
Other Ideas I’m Curious About:
  • Is there a better way to manage large numbers of searches without overloading the system?
  • Could this be extended with additional functionality, like logging search results or saving the output links?
  • Would it make sense to rewrite this in another language for added flexibility?
I’d love to hear your feedback, ideas for improvements, or suggestions for entirely new approaches to this task!
Thanks in advance for your help! ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  COLLECTION Doxing tools / OSINT tools / OSINT Guide 79bc638nw52a 6 725 3 hours ago
Last Post: Aydendjjd
  FULL list of OSINT tools Paradoxxer 2,079 221,677 8 hours ago
Last Post: Sjjskskdkddk37
  COLLECTION OSINT RESOURCES BY COUNTRY lulagain 1,801 78,999 8 hours ago
Last Post: xacjbdf
  FREE BEST OSINT TOOL 2024 9OJUT 605 30,882 Yesterday, 07:24 PM
Last Post: hevorixbro123
  COLLECTION Telegram Bots for OSINT Loki 1,113 58,754 Yesterday, 07:22 PM
Last Post: virusecurity

Forum Jump:


 Users browsing this forum: 1 Guest(s)