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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:34:50+00:00 2026-06-11T11:34:50+00:00

I am creating a batch file to siliently install nodejs on a Windows XP

  • 0

I am creating a batch file to siliently install nodejs on a Windows XP machine.

I am trying to automate the installation of node module dependencies (npm install).

I would normally issue npm install from the cmd prompt in the target installation directory.

I am struggling to automate the interaction with the command prompt from a batch file.

The following line in my batch script seems to make it possible for me to pipe a text file of commands to cmd:

for /F "usebackq delims=," %%i in ("c:\foo\source\npm_install.txt") do echo %%i | "c:\windows\system32\cmd.exe"

The batch file is located in c:\foo\source. I need to issue ‘npm install’ from c:\foo\bin.

If my npm_install.txt file is such:

  cd /d c:\foo\bin,     
  npm install

The cmd prompt will perform the first command changing the directory from c:\ to c:\foo\bin.

It will then perform the second command but starting from c:\ again. The previous command to change directories doesn’t persist. It seems every command in the text file will be issued from c:\ .

I next tried to issue both commands from a combined statment:

  cd /d c:\foo\bin && npm install

It seems this approach will allow me to overcome the prior path problem but I then have an issue with the space between npm and install.

The cmd prompt performs c:\foo\bin>npm and causes npm to trip on the space.

I have tried enclosing the command without success: ‘npm install’, “npm install”, (npm install).

Can anyone tell me what I am doing wrong?

Thanks.

  • 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-11T11:34:52+00:00Added an answer on June 11, 2026 at 11:34 am

    You do not need this:
    do echo %%i | "c:\windows\system32\cmd.exe". Simply put your commands in a block.

    do (
      command
      command
      ...
    )
    

    With your previous statement, you start new cmd interpreter, ask it to execute a command for you and exit – that’s why you loose effect of that cd.

    If you do not specify tokens in for loop, only 1st is read. Plus, all tokens must be on same line (I’m not sure if what you show is not a byproduct of formatting)
    Use "delims=" to read full line.

    Do not mix commands with arguments if you do not have to: put only directories in your file:

    c:\foo\bin
    c:\bar\bin

    so finally it becomes (I replaced cd with pushd/popd so you’ll end up in the same dir you started from):

    for /F "usebackq delims=" %%i in ("c:\foo\source\npm_install.txt") do (
          pushd %%i 
          npm install
          popd 
        )
    

    Edit: if npm install is batch itself, you will need to use call, as ebohlman noted

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

Sidebar

Related Questions

I am creating a batch file in windows with the following command in it.
I'm creating a batch file (on Windows Vista) to deploy my project from development
I am creating a shortcut of a batch file in the installation directory. I
I'm creating a batch file for SharePoint deployment. The batch will do solutions installation
I have a Windows batch file I'm creating, but I have to ECHO a
After creating a batch file in visual studio, I get an error when I
I'm creating a batch file to detect if a local printer has been installed
I'd like to request some help in creating a Batch file to run on
Looking at creating a simple batch file for my app. My app needs some
writting an MSBuild script I have found a problem. I'm creating a batch file

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.