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

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Help! Pull data from .txt

Reply to Message Icon

Name: gyi2os
Date: January 28, 2008 at 07:39:17 Pacific
OS: XP
CPU/Ram: NA
Product: 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




Sponsored Link
Ads by Google

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

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



0

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

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

for /f "tokens=* delims="


0

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

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



0

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

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Help! Pull data from .txt

Pass data from tab Controls vb.net? www.computing.net/answers/programming/pass-data-from-tab-controls-vbnet/14360.html

Batch File Read Lines from .txt www.computing.net/answers/programming/batch-file-read-lines-from-txt/16834.html

Batch pull Variable from TXT or CSV www.computing.net/answers/programming/batch-pull-variable-from-txt-or-csv/16094.html