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
  Find person on WhatsApp FREE Dionysus 60 2,204 1 hour ago
Last Post: demmama
  COLLECTION OSINT RESOURCES BY COUNTRY lulagain 1,766 71,046 1 hour ago
Last Post: NoobVendeta5
  FULL list of OSINT tools Paradoxxer 2,057 211,035 1 hour ago
Last Post: Justeunmecpassionne
  COLLECTION OSINT Tools Used By ZachXBT Sythe 204 4,520 2 hours ago
Last Post: neo_1
  BOT Search for anything email, passwords, phone, IP, full name... Dionysus 142 6,497 2 hours ago
Last Post: NoobVendeta5

Forum Jump:


 Users browsing this forum: 1 Guest(s)