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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the exe file works as expected on my computer but not for the user i need for

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi Guys,
I need some little help here
I put this code, to find open files and be able to close those files by the user who suppose to run the Exe application but i compliled, created the exe file and it does not run as it does in my computer, would like to know if you can help me here to figure out, what is wrong, the error message i get when i run it from his(user computer, by the way is a windows 7 pro 64bit) " no fields found to process", forgot to say i did this on VFP 9.0 SP1, My OS is Win xp pro 32 bit.

code at the main.prg in the project is as follow
Code:
Declare Integer ShellExecute In shell32.dll ;
	INTEGER hndWin, ;
	STRING cAction, ;
	STRING cFileName, ;
	STRING cParams, ;
	STRING cDir, ;
	INTEGER nShowWin
	
Set talk off
SET SYSMENU OFF
set sysmenu to
SET SAFETY OFF
set century on 
SET EXACT on
SET CPDIALOG OFF
Set Talk Off
Set Confirm Off
Set Century On
Set Echo Off
Set Date AMERICAN 
Set Console Off
Set Safety Off
SET EXCLUSIVE OFF
Set Deleted On
Set Autoincerror Off
Set Status Bar On
Set Exact On

LOCAL lcAppFolder
lcAppFolder = Addbs(Justpath(Sys(16,0)))
SET DEFAULT TO (m.lcAppFolder)
DO FORM ADDBS(m.lcAppFolder)+'\closefiles'
READ EVENTS

in the form load i have this
Code:
CREATE CURSOR junkopen (xID I, xuser c(10), xsystem c(10), xfiles c(100), xClose L)
INDEX on xuser+xfiles TAG xfiles

in a command buttom to execute the code i have this.
note: the "SET DEFA TO S:\PRO50", it is a share folder in the server where the user has full access and in there are all the tables that will need to be close if needed.

Code:
SET DEFAULT TO S:\pro50LOCAL oShell as wscript.shell, lcTempFile
lcTempFile = ADDBS(GETENV("TMP"))+SYS(3)+".txt"
oShell = createobject("WScript.Shell")

thisform.CoThrobber.Visible=.T.

* create a CSV list of open files in server
oshell.Run("cmd /c openfiles /query /S apexsrv1 /U chrisba /FO CSV /NH > "+m.lcTempFile,2,.T.)

* Clean it up, remove those warnings above the list
STRTOFILE(STREXTRACT(FILETOSTR(m.lcTempFile),"again.."),(m.lcTempFile))

* add records to our cursor
APPEND FROM (m.lcTempfile) TYPE CSV 

* replace this later for selective closing
REPLACE xclose WITH .F. ALL 

* Clean it up
SELECT * FROM junkopen WHERE INLIST(UPPER(JUSTEXT(xfiles)),"DBF","CDX","FPT") AND;
!EMPTY(JUSTEXT(xfiles)) INTO CURSOR junkopen2 NOFILTER 

SELECT junkopen
ZAP 
APPEND FROM DBF('junkopen2')
USE IN SELECT('junkopen2')
GO TOP 
thisform.grid1.Refresh 
thisform.CoThrobber.Visible=.F.

so actually when i press the command button to execute the code in there, i got the error "" no fields found to process"
it is like the load vent in the form, does not create the cursor in the user computer which, that cursor, should be created in the S:\PRO50 FOLDER. the exe file resides in his c:\closefiles folder, including all the libraries DLL files needed.
any help very appreciated
Thanks a lot
 
The error message comes from your APPEND FROM command, probably because your text file is empty. I suggest you check that m.lcTempfile contains the file name you were expecting. If it does, check that the file contains valid data.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
This run ok in my computer, why do you think that this won't run from another user computer, as it run in my computer ?
Thanks
 
You run "cmd /c openfiles" and it's output is not always the same. If there is no open files, then you get an empty output and APPEND FROM does not like that.
It's very likely your customer doesn't see any open files in the first run.

You forgot to handle the case with no problem, no open files.

Besides your idea doesn't work, as openfiles only see file handles made by the client it runs on. You'd have to put your EXE on the file server to which this file share is a local folder to let it see open files by any client.

Bye, Olaf.
 
Olaf,
Let me see if i understood correctly.

Are you saying that i need to actually create a folder, let's call it, "CLOSEFILES" in the server folder named "PRO50", which is a local folder in the server and by the way it is a shared folder, then inside the "CLOSEFILES" folder, add my exe file, plus all dll files needed ?

Please correct me if i am wrong

i did it as i explained above and i got the same error " NO FIELDS FOUND TO PROCESS" and believe me at this point i have a lot of DBF AND CDX FILES OPEN at least until 5:00pm eastern time.

Please if my understood was incorrect, it is not your fault, it is my English comprehension, please advice
Thanks
 
It is not even sufficient to put the exe doing the "openfiles" command into that computer. If you execute it from a client it runs on the clients computer and that doesn't see other clients file handles.
A client, yna client, will only see his own opened handles. Only the server itself will see all file handles done by any client.

That's also the essence of this:
Berezniker said:
A user running this program must be a member of the Administrators or Account Operators local group on the file server where files are located.
Plus the program has to run on the server. Just putting an exe in the file share and executing it from anywhere doesn't run it on the file server. You login to the file server OS and start the exe there.
The file server is maintaining the file handles and only this server knows about all file handles of all clients.

Bye, Olaf.
 
To reproduce the error:

Code:
StrToFile("","d:\temp\empty.txt")
Create Cursor curTest (iid I)
Append From d:\temp\empty.txt type csv
Another indicator the empty output of openfiles is causing the error.
It's not fields missing in the junkopen cursor, it's an empty csv file causing that error.
Use another way to a) really see all open files and b) also be prepared for the case the csv file is empty, eg readit in with FILETOSTR() and only appdn from it, if the string is not empty.

Bye, Olaf.

 
Olaf,

i tested this by using, the CMD and typed:

OpenFiles /query /S apexsrv1 /U administartor /FO CSV /NH > c:\test.txt

Then opened c:\test.txt

and the file has all the data i need from the server, as i specified above "/S apexsrv1" this is my server name(apexsrv1), also i ran that using the
"/U administartor" and the outcome file has all the content i need from the server, here is the test.txt file attached.

now if i do the same as above but now using "/U chrisba" which is the username who suppose to run this program, i also get the the txt file, which i named test1.txt, it will be attached here, look the content at the top and compare it to the test.txt, that is the reason why it does not work.

can you tell me how can i delete programmaticly from the test1.txt the top part ?
 
 http://files.engineering.com/getfile.aspx?folder=67ef3636-4d75-4c4d-8487-c8914855eca2&file=test1.txt
Commmon, you must test this in the scenario failing, not on your own computer. You are most probably executing it from the client having the files open, but on other clients this will not be the output of openfiles.

And to remove a first line from a text file?
Why don't you switch to the Berezniker solution? It'll not create a text file and removes that sorrow.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top