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 720573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:46:26+00:00 2026-05-14T05:46:26+00:00

This is a very basic example of what I am trying to implement in

  • 0

This is a very basic example of what I am trying to implement in a more complex batch file. I would like to extract a substring from an input parameter (%1) and branch based on if the substring was found or not.

@echo off
SETLOCAL enableextensions enabledelayedexpansion

SET _testvariable=%1
SET _testvariable=%_testvariable:~4,3%

ECHO %_testvariable%

IF %_testvariable%=act CALL :SOME
IF NOT %_testvariable%=act CALL :ACTION

:SOME
ECHO Substring found
GOTO :END

:ACTION
ECHO Substring not found
GOTO :END
ENDLOCAL

:END

This is what my output looks like:

C:\>test someaction

act

=act was unexpected at this time.

If possible I would like to turn this in to a IF/ELSE statement and evaluate directly from %1. However I have not had success with either.

  • 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-05-14T05:46:26+00:00Added an answer on May 14, 2026 at 5:46 am

    In your IF statements, replace = with ==.

    I think you also want to replace your CALL statements with GOTO.

    Here is your code, but using IF/ELSE instead of two IF statements.

    @echo off
    SETLOCAL enableextensions enabledelayedexpansion
    
    SET _testvariable=%1
    SET _testvariable=%_testvariable:~4,3%
    
    ECHO %_testvariable%
    
    IF %_testvariable%==act (
      GOTO :SOME
    ) ELSE (
      GOTO :ACTION
    )
    
    :SOME
    ECHO Substring found
    GOTO :END
    
    :ACTION
    ECHO Substring not found
    GOTO :END
    
    :END
    
    ENDLOCAL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is very basic. I would like to use jQuery to change
I'm trying to do something like in this Tutorial , a very basic gallery.
i'm trying to implement a very basic (at this point) login screen with JSF
I am trying to run this very basic socket example: import socket host =
This is very basic question from programming point of view but as I am
This is more of a MVVM application design question. I'm trying to implement a
This seems like a very basic thing to do, but I am new to
This is very basic stuff , but here goes. I find that I am
This is very basic magento question i guess. I want to first get all
This seems very basic and I must be missing something, but here goes anyways...

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.