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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:40:15+00:00 2026-06-12T07:40:15+00:00

I need help to achieve the following through a batch file. Here’s what I’m

  • 0

I need help to achieve the following through a batch file. Here’s what I’m trying to do,

  1. Run psexec to execute “systeminfo” and find the string “System Type”

  2. Determine the “System Type” (whether “X86-based PC” or “X64-based PC”) from the PsExec output.

  3. Map the drive locally on my PC and copy the file based on the system type.

Here’s my script!

@echo off
set logs="C:\logs.txt"

for /f %%i in (C:\pro_arch.txt) do (

    echo %%i >> %logs%
    PsExec.exe \\%%i -u domain\username -p "password" systeminfo | findstr /c:"System Type" >> "%Logs%"

        if "%%i"=="System Type:               X86-based PC" (
        net use m: \\%%i\C$ /user:domain\username "password"
        xcopy "C:\batch_file\x86.txt" \\%%i\C$\_support\setup\ /y
        net use m: /delete
        ) else (
        net use m: \\%%i\C$ /user:domain\username "password"
        xcopy "C:\batch_file\x64.txt" \\%%i\C$\_support\setup\ /y
        net use m: /delete
        )
)

The script works well untill this part

@echo off
set logs="C:\logs.txt"

for /f %%i in (C:\pro_arch.txt) do (

    echo %%i >> %logs%
    PsExec.exe \\%%i -u domain\username -p "password" systeminfo | findstr /c:"System Type" >> "%Logs%"

and outputs the following based on the system type:

System Type: X86-based PC
or
System Type: X64-based PC

The problem comes when the IF statement executes. It only copies the x64.txt to remote machines irrespective of the system type of the remote machine.

Command substitution using the psexec output doesn’t work either,

for /f "tokens=*" %%a in '(PsExec.exe \\IPaddress -u domain\username -p "password" systeminfo | findstr /c:"System Type")' do set myvar=%%a

it says

| was unexpected at this time

Could someone help?

  • 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-12T07:40:16+00:00Added an answer on June 12, 2026 at 7:40 am

    %%i contains the computer name, not the results of your PsExec, so of course your IF statement will never be true.

    You must either quote or escape special characters like | when used in a FOR /F DO() clause. I recommend escaping as ^|

    @echo off
    set logs="C:\logs.txt"
    
    for /f %%i in (C:\pro_arch.txt) do (
      echo %%i >> %logs%
      for /f "delims=" %%A in ('PsExec.exe \\%%i -u domain\username -p "password" systeminfo ^| findstr /c:"System Type"') do (
        >> "%Logs%" echo %%A
        if "%%A"=="System Type:               X86-based PC" (
          net use m: \\%%i\C$ /user:domain\username "password"
          xcopy "C:\batch_file\x86.txt" \\%%i\C$\_support\setup\ /y
          net use m: /delete
        ) else (
          net use m: \\%%i\C$ /user:domain\username "password"
          xcopy "C:\batch_file\x64.txt" \\%%i\C$\_support\setup\ /y
          net use m: /delete
        )
      )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Two things I'm trying to achieve and need help with 1) Click a link
I need some help using regex in java. Im trying to achieve 2 different
i'm trying to achieve the following: i want to use a tomcat accesslog file
Core Question I need help coming up with a concept to achieve my goal.
need help to create regular expression matching string www.*.abc.*/somestring Here * is wild card
really need your help with log-in-with-facebook feature I'm trying to implement on my website.
I need to achieve the following two things in bash: Give a list of
I need some help. What I am trying to do is show the locations
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above
Need help with a query that I wrote: I have three tables Company id

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.