Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:31:06+00:00 2026-06-11T07:31:06+00:00

When running this batch script the results are always the same. I believe I

  • 0

When running this batch script the results are always the same. I believe I am missing something in the syntax. What am I missing?

@echo off
netstat -an | find /C "LIST" > tmpFile
set test=<tmpFile
del tmpFile
set max=6
IF !%test! GTR !max! echo Greater than X
IF !%test! LEQ !max! echo Less than X
PAUSE
:EOF
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:31:07+00:00Added an answer on June 11, 2026 at 7:31 am
    @echo off
    setlocal EnableDelayedExpansion
    
    netstat -an | find /C "LIST" > tmpFile
    set /P test=<tmpFile
    del tmpFile
    set max=20
    IF !test! GTR !max! echo Greater than X
    IF !test! LEQ !max! echo Less than X
    PAUSE
    :EOF
    

    You need:

    1. Remove % at variable test
    2. Add key /P in set command for variable test
    3. Add setlocal EnableDelayedExpansion. See also Batch File: Fails to Echo Variable Inside Loop
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running the following batch script: @echo off tasklist /nh /fi Windowtitle eq
When running this script from Powershell or Batch: find and replace characters in Windows
I'm running this small C# test program launched from a pre-commit batch file private
Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence
I am writing a mathematica script and running it in the linux batch shell.
I am running Symfony 1.3.2 on Ubuntu. I need to write a batch script
Why is batch not running this second for loop? What am i doing wrong?
I have made this batch script which will allow the user to enter a
I'm running a test script from batch file. Because it is test, the programs
I am running a batch script and somewhere the user has to access a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.