How do I perform an operation on every machine running on the network?

A. Normally, you can use a logon script. However, if you want to run a command or copy a file to every machine, you can use the following command.

net view > list.txt

This command outputs a list of current machines to the file list.txt. You can then parse that file to perform an operation (e.g., to copy files).

FOR /F " tokens=1 " %i in (list.txt) do copy quaropts.dat "%i\C$\program files\navnt"

If you placed this command in a file, you would need to use two percentage signs (i.e., %%), as follows.

FOR /F " tokens=1 " %%i in (list.txt) do copy quaropts.dat "%%i\C$\program files\navnt"

You could change the for command as follows to avoid using a temporary file.

FOR /F " tokens=1 " %i in ('net view') do copy quaropts.dat "%i\C$\program files\navnt"
Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish