-6

I need to create a .bat script that will be executed on single/multiple machines

I need first to create a bat that prompts for the computer name that the command will be executed on it

I prefer not to use Ps tools

Sven
  • 97,248
  • 13
  • 177
  • 225
  • i have always been using psexec but we will no longer use it so i'm trying to figure out another solution i was thinking of creating a command that requests importing the computer name and after importing the computer name the batch starts automatically – MoustafaBorhan Feb 25 '15 at 11:17
  • http://serverfault.com/q/429426/118258 – HopelessN00b Feb 25 '15 at 11:18
  • Hi there thank you for your support, this helped me a lot thank you but it's not exactly what i'm looking for i need a bat file that requests from me to import the destination computer name. and after importing the destination computer name it executes a command or another bat file on it thank you in advance – MoustafaBorhan Feb 25 '15 at 11:35
  • http://stackoverflow.com/questions/26551/how-to-pass-command-line-parameters-to-a-batch-file – Reaces Feb 25 '15 at 11:37

1 Answers1

2

I prefer to provide a list of computernames:

@ECHO ON

set controlfile=control.txt

SETLOCAL DISABLEDELAYEDEXPANSION
FOR /F %%L IN (%controlfile%%) DO (
  SET "line=%%L"
  SETLOCAL ENABLEDELAYEDEXPANSION
  ping !line!
)
ENDLOCAL

But I tested this and it seems fine.

@ECHO OFF

SET /P computername=Computername:

ping %computername%

(Yes, I just pinged them, you'd need to put your own code there.)

Katherine Villyard
  • 18,510
  • 4
  • 36
  • 59