Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch an exe with text input file?

Status
Not open for further replies.

grimmy26

Technical User
Oct 27, 2003
126
0
0
AU
I have an application which essentially just switches the extended NTFS offline attribute.
What I would like to do is run this exe against a text file which has a list of files that I want to switch this attribute on for.

How can I batch this exe to run against every file that is listed in my text file?

either just a batch or vbscript would be cool


MCSE NT4, 2000, 2003
 
Suppose the file's paths are stored in a crlf separated plain text file, it is this (supposing command line is proper).
[tt]
[blue]'givens
dim exefile, txtfile
exefile="c:\xyz\yourapp.exe"
txtfile="c:\pqr\yourdata.txt"[/blue]

dim fso,wshshell,s,a,i

set fso=createobject("scripting.filesystemobject")
if not (fso.fileexists(exefile) and fso.fileexists(txtfile)) then
wscript.echo "one of the files not found, operation aborted."
set fso=nothing
wscript.quit
end if

s=""
'Last param: using system default ascii or unicode, else -1 for unicode, 0 for ascii text file
if fso.getfile(txtfile).size<>0 then
s=fso.opentextfile(txtfile,1,false,-2).readall
end if
set fso=nothing

if len(s)<>0 then
a=split(s,vbcrlf)
set wshshell=createobject("wscript.shell")
for i=0 to ubound(a)
if len(trim(a(i))<>0 then
'suppose all valid path else no recourse
on error resume next
wshshell.run exefile & " " & chr(34) & a(i) & chr(34),1,true '1 for normal (debugging), 0 for hidden
on error goto 0
end if
next
set wshshell=nothing
end if
wscript.echo "done"
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top