Solved

Report to PDF and TIF

Posted on 2014-03-19
31
780 Views
Last Modified: 2014-04-03
Hi:
I previously had a long exchange with expert Joe Winograd regarding converting PDFs to TIFs and combining multiple TIFs to one multi-page TIF within a VFP program.
Joe had suggested Irfanview with Ghostscript to accomplish this, and it tested great! I now have to put these things into a real system and am having problems that seem to be due to Ghostscript not being found, even though there is a statement in the i_view32.ini file pointing to the Ghostscript DLL.  This is due to the PDF not being converted, it creates an invalid TIF file. TIF to TIF works.
Any ideas?
Thanks.
Cathie NYC
0
Comment
Question by:ramramcat
  • 13
  • 8
  • 5
  • +2
31 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 39939247
I have just one technical hint: Download Process Monitor and check the location (folder) where is Ghostscript searched. Then simply place it to that location.

Process Monitor is available here: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39939327
I know little about Ghostscript, but it might help to (re)install it, especially if only a DLL was copied to the client, ghostscript surely is a separate installation.

VFP might just need to use that DLL, but it most probably depends on more files or on being registered or both and installing  ghostscript should do that.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39939643
Hi Cathie,
Nice to hear from you again! I have client meetings all day (and evening) today, so I won't be able to help until tomorrow. I hope you get it sorted with other experts before then, but if not, I'll jump into the mix tomorrow. Regards, Joe
0
 

Author Comment

by:ramramcat
ID: 39941543
Hi again:
After some more research, here's the problem:
* If I INSTALL Ghostscript, everything works correctly (create TIF from PDF).
* If Ghostscript is not INSTALLED, and I include the Ghostscript folder (GS9.09) within my program folder, I get a blank/invalid TIF file from a PDF when running i_view32.exe with /multitif.
* In both cases the i_view32.ini is pointing to the GS9.09 folder within my program folder.
* Using Ghostscript version GS9.10 does not improve anything.
* If I run i_view32 /multitif with TIF files, I get a combined TIF file (correct).
* My problem is that the executable and files that I am creating will reside on a server. The executable will be run on workstations using Win-XP and Win-7. I do not have control over which or how many workstations and do not want to install Ghostscript on every workstation.
* Is there any way around this, or is there any other way to convert a PDF to TIF and then use Irfanview to combine the TIFs?
Thanks.
Cathie
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39941800
Welcome in Windows World!

To require some installation is obvious Windows program "feature". Ghostscript in not an exception whereas FoxPro works well even without installation...

Installation creates folder structure, INI file, and Registry entries. Installation also copies libraries missing on the computer but required to program run.

You may prepare the Ghostscript installation package on the server and inform users having no Ghostscript installed about this necessity. To check Ghostscript existence on the computer you may read Windows Registry keys created by Ghostscript installation (more info in VFP Task Pane - Solution Samples) and also physical presence of GS DLLs on a disk.

If your program finds no Ghostscript then the message to user could say:

"Ghostscript is not installed on this PC some program features will be unavailable. Ask your administrator for assistance. The installation package is located on ... "
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 39941980
As I recall, there's logic in Ghostscript to install itself, if needed.  I'll do a bit of research to confirm or refute my recollection.
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39942102
So the situation is as I assumed. Just copying the Ghostscript folder is not enough.
Partially it works, eg the multitif.exe works without further registration and runtime installations, but that's not the norm.

There are ways to install on all clients via centralized WSUS software distribution, for example, that's one MS solution to that organisational problem. If the company has an IT department ask them, how they manage company wide client installs, and if they can simply add Ghostscript to their standard software package.

Another option is having one local installation at eg the server and letting it do that job. Of course since it's only working on the server, the start mechanism can't be RUN from the client side. You have to have some application module also installed locally at the  server, which eg takes commands to be executed via a job.dbf, where you simply insert what data or files to process. Your server side module would look into that job table for new records, process and delete them, perhaps signalling back in another field of that dbf, where the result pdf or tif file is stored.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39944599
Cathie,
Sorry I didn't participate in this today. It's on the to-do list for tomorrow. Regards, Joe
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 39945131
Apparently, my memory was faulty - as though that has never happened before.  The 'self-installation' that I remembered is actually part of a class definition built around Ghostscript, not part of GS itself.  It does seem that GS is not registered with Windows, however, so you could probably include logic in your app to copy it to the workstation the first time it's needed.
0
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 300 total points
ID: 39945510
Hi Cathie,
Sorry for taking so long to respond (was onsite at a client...it was supposed to be one day but wound up being two). Let me start by correcting a couple of things in this thread. First, Ghostscript does not need to be installed. All you need is the <gswin32c.exe> executable to be located in the same folder as <gsdll32.dll>. I suggest putting both files in the same folder as <i_view32.exe>. As you already know, IrfanView also does not have to be installed...just have <i_view32.exe> and <i_view32.ini> in the same folder (along with the Plugins subfolder). As we discussed the last time, you must use the 32-bit version of Ghostscript, even on 64-bit Windows, because IrfanView is a 32-bit program (of course, that's only when you need PDF support in IrfanView).

Second correction is that someone mentioned <multitif.exe>. There's no such thing in the IrfanView world. The executable is <i_view32.exe> and there's a parameter that can be passed to it called "/multitif" (but I'm sure you're aware of this).

Now on to the solution for you. In the same manner that you are making a command line call in your VFP program to <i_view32.exe>, you can make a command line call to <gswin32c.exe> (I'll emphasize again — without having to install it, as long <gsdll32.dll> is there). To learn all of the command line options for <gswin32c.exe>, run it with the -help param, i.e.:

gswin32c -help

Here's a common execution of it:

gswin32c -dNOPAUSE -q -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf

Here's what the params mean:

-dNOPAUSE: no pause after each page

-q: quiet operation

-sDEVICE=tiffg4: create an ITU-T (formerly CCITT) Group 4 TIFF file...we discussed this in the previous thread relative to IrfanView's "/tifc" param (TIFF compression)

-dBATCH: exit after last file is processed

-sOutputFile=output_file_name.tif and input_file_name.pdf: both obvious

I tested this on a 3-page PDF file in a W7 sandbox that has neither IrfanView nor Ghostscript installed. Here's what the test folder looks like:


IrfanView-Ghostscript test folderThe <test3page.tif> was created via this command:

gswin32c -dNOPAUSE -q -sDEVICE=tiffg4 -dBATCH -sOutputFile=test3page.tif test3page.pdf

After you've called the command line <gswin32c.exe> to create TIFFs from the PDFs, you may then call the command line <i_view32.exe> with the "/multitif" param to combine the multiple TIFF files into a single multi-page TIFF file. IrfanView won't need Ghostscript (or ImPDF) at that point, since it will be dealing strictly with TIFF files.

I think that's it. This should work for you, but if you have any problems, let me know. Regards, Joe
0
 

Author Comment

by:ramramcat
ID: 39946890
Hi Joe:
Thanks for getting back.
I am combining 2 tif files with 1 pdf file. It works when GS is installed.  
I uninstalled GS, copied gswin32c.exe and the DLL into my folder with Irfanview. When I run the 2 steps (gswin32c and then i_view32), all that ends up in my output file are the 2 original tif files and the pdf is nowhere to be found.
If there's something else to try I will, but at this point, if they need to install GS, so be it.
Thanks.
Cathie
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39946907
Cathie,
Do not combine the two TIFF files and one PDF file with IV. Instead, use gswin32c to convert the one PDF file into TIFF. That will work as I described above without needing to install GS. Then combine the three TIFF files into one TIFF file using IV. That will work as I described above (and in our previous thread) without needing to install IV.

In fact, with this approach you won't need the PlugIns subfolder, since you won't be using IV to process PDF. All you'll need in your folder is the VFP executable (and support files, if any, such as DLLs), and these four files:

i_view32.exe
i_view32.ini
gswin32c.exe
gsdll32.dll

That's it!

To remind you of the IV "/multitif" call from our last thread, use this in your VFP program:

i_view32.exe /multitif=(combo.tif,in1.tif,in2.tif,in3.tif) /killmesoftly /silent /tifc=4

I just ran the gswin32c.exe command from my previous post and the i_view32.exe command from this post in my sandbox that has neither GS nor IV installed and has only those four files shown above in the folder (without the PlugIns subfolder) and it worked perfectly.

Btw, processing PDF with IV is when you need to have GS installed (I haven't found a way around that...yet) and when you need the PlugIns folder (actually, just certain modules in it). But with the approach outlined here, you won't be processing PDF with IV. Regards, Joe
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39947121
Joe, that's fine news.

Still these 4 files you list may have further dependencies to eg a C/C++ runtime installed on your sandbox, a runtime already present in your system by Windows itself or any other installation.

Cathie, if you have these files installed and the execution of i_view32.exe and/or gswin32c.exe still does not work out, then check out if there are further dependencies with the tool dependencywalker you can get from http://www.dependencywalker.com/

It'll surely show many dependencies to system DLLs, every windows executable has these dependencies and running on any windows version is mostly enough. Still watch out for any further DLLs not found Joe may have on his sandbox PC or VM, not part of your windows version.

Also registered classes of some EXE or DLL could still be used, even if calling an EXE in a separate folder. Processmonitor would be another tool to find out eg by monitoring calls to CoCreateInstance within some exe(s), see http://technet.microsoft.com/en-US/sysinternals/bb896645.aspx

Bye, Olaf.

Edit: Further dependencies may include a certain version of gdiplus.dll or mcvrt or anything else, which is present on your system, but too old or even too new.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39947882
Hi Olaf,

My experience with Dependency Walker is that it shows too much information to be helpful. I write a lot of programs that compile into a stand-alone/no-install/zero-dependency EXE. The EXEs that the compiler produces run on every workstation I've ever tried them on, from XP through W8, and everything in between, both 32-bit and 64-bit. But Dependency Walker shows a mind-boggling list of dependencies, even on a one-line MsgBox program that displays Hello World.

In any case, Cathie is a developer/programmer at a company. She could grab a new machine from inventory, where nothing has been installed other than the factory OS, and try <gswin32c.exe> and <i_view32.exe> on that. Alternatively, she could install a virtual machine environment and load a clean W7 and/or W8 on it. However, she could also just try it in her real world. In her opening question, she said, "I now have to put these things into a real system and am having problems that seem to be due to Ghostscript not being found..." I predict that she will no longer have these problems with her "real system" if she stops trying to process PDF files in IrfanView, and instead converts the PDF files to TIFF files with the command line <gswin32c.exe>, and then uses the command line <i_view32.exe> to combine the TIFF files. Regards, Joe
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39948265
Hi Joe,

well, first our experiences with dependency walker differ, obviously. A missing DLL is shown red, so you easily find that.

If, as you found yourself, Cathy is not following your previous instructions, using IrfanView instead of gswin32c.exe, then changing that to using gswin32c.ee will resolve the problems, most probably.

It won't hurt to start dependency walker on an exe or dll not working as expected, to see what it needs additionally, to run.

Bye, Olaf.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39948275
Hi Olaf,
I don't want us to hijack the thread away from Cathie's issue, so let's just agree that, as you said, our experiences with Dependency Walker differ. You're right that it won't hurt to run it on an EXE or DLL not working as expected, but my experience is that it won't help. Btw, I did run it on <gswin32c.exe> and <i_view32.exe>, with unhelpful results. In any case, I feel strongly that Cathie will be fine in her "real system" as I've outlined above. Cheers, Joe
0
 

Author Comment

by:ramramcat
ID: 39952413
Hi Joe / Olaf:
I've needed a few days (again) to deal with other issues...I did try running two commands (gswin32c.exe and i_view32.exe) to no avail...no files created. Just so you understand, we don't have a PC inventory, I currently have an XP PC and a W7 notebook. The client currently is using XP and will be soon upgrading to W7.
I'll try again when the dust settles.
Thanks for all the attention.
Cathie
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39952431
Cathie,
Please post the exact gswin32c.exe and i_view32.exe commands that you ran. A copy/paste of both commands, please. Thanks, Joe
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39952512
>I did run it on <gswin32c.exe> and <i_view32.exe>, with unhelpful results.

What do you expect. If these EXEs run in your system, you don't have any missing dependency. Dependency walker of course needs to run on a system, where the EXE isn't working, so your fruitless run doesn't prove it also won't be helpful for Cathie.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39960479
Olaf,
Fair enough. So how about this. I just received a brand new W7/64-bit machine that I'm configuring for a client. I turned it on, ran through Windows first-time setup, and let it update MSE to the latest data file. That's it. Did not install anything at all.

I then put a USB stick in the machine (came up as the D drive) with these four files in a folder called ivghost:
i_view32.exe
i_view32.ini
gswin32c.exe
gsdll32.dll

It also had these two test PDF files:
test2page.pdf
test3page.pdf

The <i_view32.ini> contained only these three lines:
[Language]
DLL=ENGLISH
Lang=English

I then opened a command prompt, navigated to <d:\ivghost>, and ran this:

gswin32c -dNOPAUSE -q -sDEVICE=tiffg4 -dBATCH -sOutputFile=test2page.tif test2page.pdf

It worked perfectly, creating the 2-page <test2page.tif>. Did the same thing with <test3page.pdf>. It worked perfectly, creating the 3-page <test3page.tif>.

Then ran this:

i_view32 /multitif=(combined.tif,test2page.tif,test3page.tif) /killmesoftly /silent /tifc=4

It worked perfectly, creating the 5-page <combined.tif>.

This proves that neither <gswin32c.exe> nor <i_view32.exe> needs to be installed and, furthermore, that neither requires any additional software installation, other than what comes standard/out-of-the-box on W7 Pro 64-bit. Are you convinced now?

I suspect this would work fine for other W7 flavors, and even other versions of Windows (XP, Vista, W8), but, of course, I can't say that with certainty.

Cathie,
As I mentioned earlier, please post the exact <gswin32c.exe> and <i_view32.exe> commands that you ran. Please do a copy/paste for accuracy. Btw, the upper/lower case on the GS parameters is very important — they are case sensitive. Regards, Joe
0
 

Author Comment

by:ramramcat
ID: 39965985
Hi Joe:

Here is the code. There are a lot of substitutional parameters, partly because VFP only allows a "RUN" command of 240 characters and the folders/filenames being used are lengthy. At this time I get no TIF output at all (I used to get a TIF that contained only the TIFs that were input (named infile1 and infile2).

COPY FILE (M_ImgDir)+cFilename TO L:\fedmfv\work\Infile1.tif
COPY FILE M_ImgDir+SUBSTR(cFilename,1,25)+"-2.TIF" TO l:\fedmfv\work\infile2.tif
COPY FILE M_PDFDir+SUBSTR(cfilename,1,4)+SUBSTR(cfilename,13,3)+SUBSTR(cfilename,16,10)+"-3.pdf" TO l:\fedmfv\work\infile3.pdf

STORE "l:\fedmfv\work\infile1.tif" TO infile1                  && Scanned P1
STORE "l:\fedmfv\work\infile2.tif" TO infile2                  && Scanned P2
STORE "l:\fedmfv\work\infile3.pdf" TO infile3                  && Generated PDF
STORE "l:\fedmfv\work\infile4.tif" TO infile4                  && Generated TIF from PDF
STORE LOWER('&M_Tifdir'+SUBSTR(cFilename,16,10)+".tif") TO OutFile      && New 3-Page TIF File      

RUN /N7 l:\fedmfv\irfanview\gswin32c.exe -dNOPAUSE -q sDEVICE=tiffg4 -dBATCH -sOutputFile=&infile4 &infile3
RUN /N7 l:\fedmfv\irfanview\i_view32.exe /multitif=(&outfile,&infile4,&infile1,&infile2)/killmesoftly/silent/tifc=4

Thanks.
Cathie
0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 200 total points
ID: 39966268
Joe,

fair enough, but whatever isn't working for Cathies PC might have to do with this specific PC and whatever has been done with it, both installs, uninstalles, setups, updates... I'll assume the EXEs work without any dependencies for now, anyway.

Cathie, you may have a very simple and easily overlooked problem: A space in a file name, that file name then has to go into quotes. From what we can see there is no space, but what comes in as cFilename is unknown.

Besides you may hit the length limit. To give Joe better input of what the command lines are you finally execute, you could do this right before the two RUN commands:

lcCommand1 = [l:\fedmfv\irfanview\gswin32c.exe -dNOPAUSE -q sDEVICE=tiffg4 -dBATCH -sOutputFile=&infile4 &infile3]

lcCommand2 = [l:\fedmfv\irfanview\i_view32.exe /multitif=(&outfile,&infile4,&infile1,&infile2)/killmesoftly/silent/tifc=4]

_cliptext = lcCommand1+chr(13)+chr(10)+lcCommand2
set step on

Open in new window

Now paste the clipboard content here, that'll give exactly the commands run with expanded macro substitution (&) of file names etc. You would also see the length the commands will have.

There are easy ways to shorten at least the path to the two EXEs by adding their paths to the Windows system environment variable %PATH'% in Windows System advanced settings.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39966776
Hi Cathie,
You may recall the issue of quotes around file names the last time. Your conclusion at the time was:
The PDFtk and IV-multitif commands work perfectly through VFP! There are no quotes (") required, most likely due to no more spaces (I would use them if there are spaces in filenames).
But perhaps this time there are spaces in the file names, necessitating the quotes.

Btw, is just IV failing or is GS failing, too? In other words, is the call to GS creating the output file named <&infile4>? Regards, Joe
0
 

Author Closing Comment

by:ramramcat
ID: 39968679
Joe's solution of using separate command lines for Ghostscript and for I_View32 solved the problem of creating a TIF from a PDF and then combining 3 TIFs into one (new) TIF.
Neither Ghostscript nor Irfanview are 'installed' on the PC.

Olaf's suggestion of using _cliptext to see the expanded macro substitution was extremely helpful in debugging my code. I did not know of _cliptext  before this - VERY useful!

Thank you both for your time and patience.

In addition to the above, I needed to add a 'WAIT "" TIMEOUT 5' statement after each RUN command, as it takes a bit long to create a TIF from a PDF and the subsequent commands were happening too fast. The WAIT statements resolved that.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39969398
Hi Cathie,
Very happy to hear that all is working well with neither GS nor IV installed — that is great news!

Rather than waiting for a certain amount of time, which could vary significantly depending on the size of the files (and you could even have a case where you haven't waited long enough for the file to be created, causing the program to fail), is there a statement in VFP like RUN, but that waits until the run is finished? As I mentioned in our first thread together, I know nothing about VFP, but most other procedural languages have a "run-and-wait-until-done" statement. For example, I do most of my programming these days in a language called AutoHotkey. It has these three statements related to running external programs:

Run: Runs an external program.
RunAs: Specifies a set of user credentials to use for all subsequent uses of Run and RunWait.
RunWait: Runs an external program and waits until it finishes.

Look at the VFP manual to see if it has something similar to AutoHotkey's RunWait statement. If not, then you could put in a Wait loop checking for the existence of the output file...something like this (since I don't know VFP, below is generic programming code...I'm sure you can translate to VFP):

Delete &infile4
RUN /N7 l:\fedmfv\irfanview\gswin32c.exe -dNOPAUSE -q sDEVICE=tiffg4 -dBATCH -sOutputFile=&infile4 &infile3
Loop forever
  If &infile4 exists then break loop
  Else wait one second and continue loop
End loop
comment: will arrive here only after the RUN command above has created &infile4
RUN /N7 l:\fedmfv\irfanview\i_view32.exe /multitif=(&outfile,&infile4,&infile1,&infile2)/killmesoftly/silent/tifc=4

Regards, Joe
0
 
LVL 2

Expert Comment

by:GEOFS
ID: 39969698
Regarding the 'wait until file exists loop', I have used this technique in various situations, including generating PDF's with Ghostscript.  On occasion, the directory entry for the file being created is made before the file is fully populated, which then caused issues with the next phase of the job.  In those cases, I changed the loop to continue until the file size remains constant from one loop iteration to the next.

Alternatively, you could do something like this:

oShell = CREATEOBJECT("wscript.shell")
ccmd = "notepad c:\temp\puzzle.txt"
oShell.Run( ccmd, 3, .t. )

The third parameter, .t., tells the caller to wait until the called app is finished.  I discovered this technique only recently and haven't had an opportunity to actually use it yet.

Geof
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39969869
> On occasion, the directory entry for the file being created is made before the file is fully populated

Geof, excellent point! I hadn't thought of that when I proposed the loop as an alternative if the language doesn't have a "run-and-wait-until-done" statement. You are correct that the "if-file-exists" statement could be True even though the file hasn't been fully written yet.

Cathie,
As I said before, I've never used VFP. But to put this issue to bed, I just looked up the RUN command in the VFP manual. It turns out that the problem is that you're using the /N option. Here's the definition:

/N means NOWAIT. Include the letter N to execute another Windows-based application and return control immediately to Visual FoxPro.

If I'm reading this right, it means that RUN without the /N option is "run-and-wait-until-done". In other words, in order to return to the program without waiting until the external program is finished, you must include the /N option. So it seems that the answer for you is simply to remove the /N option from your RUN statements. Regards, Joe
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39970274
Joe, good point and good job reading about a language you even don't use. There is another difference using /N or not using it. A console window appears, if not using it, as the difference is running the specified exe directly or via %COMSPEC% (typically cmd.exe).

Using Wscript.Shell Run really offers the best solution, as you can decide whether to show a console or not, whether you wait for the exitcode of the app or not.

I'm currently using the Wscript.Shell Exec method, which gives you an object having Stdin/Stdout/Stderr properties you can use to communciate with the started process. That won't play a role here, but illustrates the versatiliy of Wcript.Shell.

You could also make use of CreateProcess, but it's needing a PROCINFO struct and working with structs is ugly in VFP. On Top of that you then could use WaitForSingleObject to wait for the exit of the spawned process, and do something else meanwhile. But it's not worth the hassle to save the user 5 seconds wait time.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39973144
Hi Olaf,
Interesting stuff! Does VFP allow direct specification of %comspec%? For example, the following line in an AutoHotkey program will invoke %comspec% with the /c param:

RunWait,%comspec% /c "d:\0tempd\hello world.exe",,Hide

The Hide param is an AutoHotkey construct that launches the app hidden, so when the target app is %comspec%, you won't see the command prompt window. Of course, sometimes %comspec% is not needed, so the AutoHotkey code in the above example may be this:

RunWait,"d:\0tempd\helloworld.exe"

What's the scoop with VFP? Regards, Joe
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39976449
Well, VFPs RUN really branches on what it does, if using the /N switch or not. using /N you start the specified EXE directly and continue right away, quite the same as a WIN API call to ShellExecute() does.

Not using /N you start what is specified in %comspec% and pass on the rest to it, so RUN dir >d:\dir.txt is the same as running dir >d:dir.txt inside the cmd.exe console window, while RUN /N dir does not find a dir.exe and fails. /N is not just a wait or not wait switch, it switches what RUN is itself.

The best way to change the behavior of RUN would be to change the %comspec% system variable, but that obviously would effect the whole system and would also need higher privileges to change this system environment variable.

Another way out is using Windows API. VFP has a DECLARE command to make a declaration of any DLL function (function libraries, not assemblies), eg classic Win API functions, so you can make use of anything like CreateProcess, ShellExecute, WaitForSingleObject, etc. VFP also can use COM classes, like Wscript.Shell, Shell.Application, Scripting.Filesystemobject, Office Applications, etc. etc.

Bye, Olaf.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
ID: 39976522
Olaf,
Thanks for the explanation — much appreciated! Cheers, Joe
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
In this article, I show you step by step with screenshots to assist you - HOW TO: Deploy and Install the VMware vCenter Server Appliance 6.5 (VCSA 6.5), with some helpful tips along the way.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now