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

  • Home
  • SEARCH
  • 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 6144525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:39:48+00:00 2026-05-23T18:39:48+00:00

Basically, I want to copy the latest version of an MSI from a server

  • 0

Basically, I want to copy the latest version of an MSI from a server to my local machine. I am trying to loop through a file and grab the first line which holds the latest version of the MSI to grab. I am not entirely familiar with the weirdness of for loops and if statements in batch files. Here is the code I have that keeps looping after it finds the first line:

cd %~dp0

mkdir "c:\MyApp\QA\msi"

rem Determine what folder is the latest version of QA
setlocal enabledelayedexpansion
dir /b /o-n "\\my-server\folder\another_folder\5.0.*" > output.txt
SET /a counter=1
SET version=""
for /f "usebackq delims=" %%a in (output.txt) do (
if "counter"==1 goto install (
xcopy "\\my-server\folder\another_folder\%%a\myinstaller.msi" "c:\MyApp\QA\msi\myinstaller.msi" /y
)
SET /a counter+=1
)

goto exit

:exit

PAUSE
  • 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-23T18:39:49+00:00Added an answer on May 23, 2026 at 6:39 pm

    In this line:

    if "counter"==1 goto install (
    

    "counter" can never be equal to 1. On the other hand, !counter! might.

    Explanation (in case you need it):

    "counter" is a literal, a word counter in double quotes. You are comparing it to another literal, 1. Obviously the two don’t match. What is most probably meant in that part of the script is evaluating the variable counter and comparing the value with 1. In bracketed command blocks one typically uses delayed expansion, hence !counter! (as opposed to %counter%).

    On a different note, the said line seems somewhat unusual. It contains the goto command and another command after it. I don’t think that the command that follows goto is likely to be executed. Possibly goto install is redundant.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to basically copy whats from the clipboard and paste it in a
I am trying to copy one table over another one atomically. Basically I want
I have a local SQL Server Express database that I want to copy to
Basically I want to copy the behavior in iPhone's Calendar where the day of
I basically want to open a browser window from Word using VBA that does
What i basically want to do is to get content from a website and
Suppose I have the following data but I basically want to copy the first
How do I loop through a collection? I'm on a trial version of Fujitsu/Alchemy
I have a revision.txt file in my SVN project. Basically I want that this
I basically want to use link_to to link to the index method of 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.