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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:17:20+00:00 2026-06-12T09:17:20+00:00

I am currently writing a Batch file (first time doing so) to remotely call

  • 0

I am currently writing a Batch file (first time doing so) to remotely call machines in our network (all embedded XP) and schedule a defrag at 11:00PM (23:00).

Of course, it isn’t going as planned, that is understandable. However, I would like to get the logging information that would typically be given at command prompt, such as ‘disk is -% defragmented’ or errors, etc. My current stage of the line that makes the call is this:

@FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 defrag C: /A > C:\...\log.txt

NOTE: The ellipsis in between C:\ and \defraglog.txt actually have the full pathname typed. For context, %List% is a list of IP addresses.

However, defrag never even launches. According to the remote computer I am testing on, the command looks like:

defrag C: /A and C:\...\log.txt

when I look at Scheduled Tasks.

Now, when I simply use:

@FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 defrag C:

I do get a defragmentation scheduled at 11:00PM on the remote machines, so I am assuming the issue lies in the way I am redirecting.

Any help would be greatly appreciated!

  • 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-12T09:17:20+00:00Added an answer on June 12, 2026 at 9:17 am

    I would try adding quotes:

    @FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 defrag C: /A > %APPDATA%\log.txt
    

    If that doesn’t work, make a batch file defragXP.cmd on a network share that holds:

    @echo off
    defrag C: /A > C:\...\log.txt
    

    and then schedule the batch:

    @FOR /F "Tokens=1" %%a IN (%List%) DO at \\%%a 23:00 \\server\batches\defragXP.cmd
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing a .bat batch file that executes an installation file. Before
I'm currently writing a simple batch script to set the DNS of a LAN
I'm currently porting some batch files to node.js. I feel more comfortable writing in
I'm currently writing a function what would create a zip file, which will be
I'm currently writing a billing application using EF 5 Code First, and I'm running
I am currently writing an app that calls for the recording and real time
I'm currently writing Bitmaps to a png file and also reading them back to
I need some help in writing a batch file. I have a path stored
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
I am currently writing a PowerShell script that parses an XML file, and it

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.