Computing.Net > Forums > Programming > Batch Help! Pull data from .txt

Batch Help! Pull data from .txt

Reply to Message Icon

Original Message
Name: gyi2os
Date: January 28, 2008 at 07:39:17 Pacific
Subject: Batch Help! Pull data from .txt
OS: XP
CPU/Ram: NA
Model/Manufacturer: NA
Comment:

Hello,

I've searched the forums but what i find isn't quite what i need(Or i don't know how to mod them to work for me).

What i am trying to do is this:


Copy an .exe to all in list

psexec file on all in list

pauses on all in list

pskill all the processes on all the computers in list

del file from all in list.

************

What i have is this:
_________________________
echo off
echo Hello

copy "c:\lil programs\ld\ld.exe" \\Computer\C$


psexec \\Computer -s -d c:\ld.exe

ping -n 30 127.0.0.1

pskill \\Computer ld.exe | del \\Computer\c$\ld.exe

pause
exit
__________________________


So as you can see, i need to manually change "Computer" to the computer name every time... in four places in the batch. This script does work perfectly on a one time basis. The only problem is, i need to do this on 500+ machines in batches of 20-30 computers at a time.

What i'd like to do is be able to enter the 20-30 computer names in a .txt and have the script go through the .txt and run the copies on all in the list, then psexec all, then pause, then kill the process, then delete the file.

If you could please provide some insight into the easiest, most straight forward way to do this, that would be excellent.


Extra internet points if you help me 'learn' how to do this, (providing a breakdown of "This portion does this, that does that" so i will be able to apply this to other projects in the future without the need for outside help.)

Thanks!
Nick



Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: January 28, 2008 at 08:24:39 Pacific
Reply: (edit)

Where do I redeem my points? LOL

::=========================
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (myLIST.txt) do (
echo copy blah "%%a"
echo psexec blah "%%a"
echo and so on
)



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: gyi2os
Date: January 28, 2008 at 08:31:43 Pacific
Reply: (edit)

Out of curiosity, what is the purpose/function of...

for /f "tokens=* delims="


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: January 28, 2008 at 08:41:29 Pacific
Reply: (edit)

tokens=*

means 'use the whole line'

delims= [space]

means 'use SPACEs & TABs as separators' in this case, not important. I always use them unless they would gum up the works.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 4
Name: Razor2.3
Date: January 28, 2008 at 18:05:12 Pacific
Reply: (edit)

Also, PSEXEC will copy the program to the target PC, so there's no need to do it manually.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Batch Help! Pull data from .txt

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge