-1

Noob here. I have a local fileserver set up. I want to write a batch script that runs a certain name.exe on every client that is active on the server. So basically, when I run the batch file, name.exe runs on every connected, active client. Not sure how to go about this.

Any help is appreciated. Thanks!

David Clarance
  • 354
  • 3
  • 10
  • Please learn [how to ask](http://stackoverflow.com/help/how-to-ask) here! Your question is way too broad for this site! – aschipfl Jul 13 '16 at 19:42

1 Answers1

0

To generate a list of computers that are turned on, (in a batch file use %%A rather than %A when typing interactively)

for /f "skip=3 delims=\" %A in ('net view ^| findstr /v /C:"The command completed successfully"') do Echo %A >> "%userprofile%\desktop\computername.txt"

To run a program use (NB: remote programs are invisible on the remote computer because you can't interfere with a user). Note the use of double backslashes for the command line.

wmic /node:@"%userprofile%\desktop\computername.txt" /failfast:on process call create "c:\\windows\\notepad.exe"

See wmic /?, wmic process /?, wmic process get /?, wmic process set /?, wmic process call /?, wmic /format /?, wmic /node /?, and wmic /failfast /?. Also for /?, net help view (net view /? is short help) and findstr /?.

To see what punctuation means see Trouble with renaming folders and sub folders using Batch

Community
  • 1
  • 1