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!

Batching an exe against 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?

MCSE NT4, 2000, 2003
 
This a FoxPro question? I'd use shellexecute and pass the file as a parm.

Code:
CLOSE ALL
m.cDir = JUSTPATH(SYS(16))
SET DEFAULT TO &cDir

STRTOFILE("Test1","test1.txt")
STRTOFILE("Test2","test2.txt")

DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
  INTEGER nhandle, STRING @sFile,;
  STRING @lp, STRING @DIR,;
  STRING @dir1, INTEGER ncmd

FOR i = 1 to adir(aa,ADDBS(m.cDir)+"test*.txt")
  SHELLEXECUTE(0, "open", "C:\WINDOWS\system32\notepad.exe", ADDBS(m.cDir)+aa[m.i,1], "", 1)
ENDFOR
[code]
 
You could use ALINES() to get the filenames into an array, and then loop through the array. Something like this:

Code:
LOCAL lnI, lcFile
LOCAL ARRAY laFiles(1)

ALINES(laFiles, FILETOSTR("FileList.TXT"))

FOR lnI = 1 to ALEN(laFiles)
  lcFile = laFiles(lnI)

  * Do something here with the file

ENDFOR

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I have a feeling it isn't a VFP question, but the shellexecute tip should be helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top