Checking for a file on C: drive
Posted 21 February 2007 - 05:47 PM
Does anybody know of a good way to check from PROIV if a file exists on the C drive? I was going to write a simple VB prgram but I have the same problem if the exe does not exist.
if you are running under windows then the following has worked in Pro-IV since the begining
IF #STAT = -1 THEN
UMSG('Import File is Not Present .... ',-1)
// File exists
Posted 22 February 2007 - 07:20 PM
I have used SYSf before to check for files on windows and Unix. The problem is I am on Unix and I want to check if a .exe exists on C:.
I tried doing a system command with a pipe to a text file but windows pops up a window and then removes it. This doesn't lookt that good so I was looking for something cleaner.
Posted 24 February 2007 - 01:08 PM
take a look at this thread, it may be helpful in resolving your current issue
additionally in whatever command you issue is it possible to re-direct the I/O to prevent the windows dialogue box etc.,
Posted 26 February 2007 - 05:09 PM
I did redirect the output but Windows still pops up a window for a split second.
I have managed to solve the problem by writing a small VB program to do the checking. I pass the full path + filename to the VB program and it sends back a return code. The problem with using a VB program is you need to make sure the VB program exists on each client machine. To get around this I have transferred the .exe to the server and I do a CLIENT.Send of the file to the PC before I do the system command to call the .exe. The .exe file is tiny so when I do the transfer it takes no time to do it and I know the .exe will always exist on the client pc. I have run it and it works a treat.
Thanks for your help.
Posted 08 October 2007 - 07:37 PM
This may be well known by now - but it may mean that you can simplify your VB maintenance.
To identify if a file exists use:
#A = CLIENT.Execute($FILE,"",$PATH,"SW_HIDE")
The hide means (on my XP pro set up anyway) that the application isn't opened. The value of #A will show the status you're looking for if the the path and filename are correct. See the manual for all the return code meanings (zero - exists, 2 - file not found, 3 path not found)
Posted 08 October 2007 - 07:46 PM
Haven't tried it Donald, but doesnt that run the application rather than check the file?
SW_HIDE means run the application, but keep the application from dispalying.
However, I could be wrong...
Posted 08 October 2007 - 09:28 PM
You'd have thought so - wouldn't you? But when I tested it with SW_HIDE there was no additional application on the start bar.
Using SW_SHOWNORMAL opens the app with the appropriate file and the window is the current one
SW_SHOWMINIMIZED opens the app but it's not shown as a window - it has to be "restored" or closed
SW_SHOWNOACTIVE (and SHOWNA) opened the app but it wasn't the current window and the current window was still behind it.
But with SW_HIDE the app may have been opened but it's then immediately closed. There is no indication of the app being opened. Either that or it's hidden somewhere else..... I'll check with the task manager.
Posted 08 October 2007 - 09:46 PM
It must run the app tho cos if the file and dir are correct 0 is returned. If the filename is incorrect then 2 is returned. Maybe it's too fast to register (even on my aging laptop).
It might be interesting to know which is quicker: CLIENT.GetPath or CLIENT.Execute using SW_HIDE. And of course the Execute can only be used on file extensions that trigger an application (probably).
Just thought it might be useful....
Posted 09 October 2007 - 06:31 AM
But SW_HIDE is a const that is normally used in other languages to start an app, but dont display it in the task bar or on the screen, kind of running it in the back ground.
I would presume that is what Client.Execute is doing...
Maybe there is a bug with Client.execute & SW_HIDE.
Reply to this topic
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users