×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

ShellExecute question

ShellExecute question

ShellExecute question

(OP)
Hello all. I have a VFP 9 program which calls an EXE to create PDF files and another EXE to zip the numerous PDF files into a single zip file. The EXE's are executed using ShellExecute. This accomplishes the desired result however, each time ShellExecute runs there's a very brief flash of a DOS window which is very unattractive. The syntax is = ShellExecute(0,"OPEN","---.EXE","----params----","",0). The DOS windows that flash on the screen have a header of "c:\windows\system32\cmd.exe". While this action does not effect the ultimate result, it's very distracting to the user considering the program typically makes 500 +/- calls to ShellExecute. Any help will be appreciated.

RE: ShellExecute question

RUN would cause a "DOS" window (it's a shell window) to appear. ShellExecute does not. I don't think it ever does, also in variations using 0 as ShowWindow parameter, which means your EXE is not shown.
the usual usage of Shellexecute is with ShowWindow=1, and it only shows the window of the EXE you call in "normal" state (1 = SW_SHOWNORMAL), not a shell window.

If you see aa shell window, then this could come from something you call from your EXE, like pkzip or arj or whatever compression utility you use that's perhaps used as console application. They also show a "DOS" window (its a console window this time).

Chriss

RE: ShellExecute question

(OP)
Chris, thanks for your response. You're obviously correct about RUN vs ShellExecute. I've used ShellExecute many times in the past to, among other things, avoid the opening of a "DOS" window. So I think you have correctly identified the problem that either the zip EXE or pdf converter EXE are causing the problem. More likely the PDF converter, based on the number of times the windows flash across the screen. I'll explore that possibility further. Thanks again.

RE: ShellExecute question

I agree. It is clear that the DOS window is being opened by one of the programs that ShellExecute() is executing, not by ShellExecute() itself. So what are those programs - the ones you are using to zip the files or produce the PDFs?

As you no doubt know, there are various ways of producing PDFs from within VFP that don't involve running a DOS program. If the PDFs are coming from a VFP report, you could use XFRX or FoxyPreviewer to create them - in both cases it is possible to do that without any user interaction. Or you can simply "print" the reports to a PDF driver such as CutePDF or PDF Complete.

Similarly for zipping the files.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: ShellExecute question

(OP)
Thanks for your input Mike. I agree with you & Chris based on the fact that I've used ShellExecute() many times in the past and have never encountered this problem before. I don't think the culprit is the zipping at the end of the program (btw it's WinZip command line). Even if it does behave this way, it's not a big deal because it is called once after all of the PDF's have been produced. The PDF's produced from hundreds of print files produced during program execution seem to be causing the problem. The system is a very old accounting system originally developed in Foxpro 2.5 (DOS based). While it has been modified to run as a VFP 9 app, the many, many report programs still produce PCL files and that's what my program is converting to PDF's using PCL2PDF. PCL2PDF is a command line utility and has an optional parameter for "silent" so as not to display any feedback. However, I'm sure it still opens a "DOS" window which is what the user is seeing when my program is executed. I will check out CutePDF & PDF Complete to see if either is an appropriate replacement for PCL2PDF.

RE: ShellExecute question

It's actually controllable by the last parameter of ShellExecute, whether the window of that application should be shown normal, maximuzed, minimmized or not at all.

Quote (diesel6460)

btw it's WinZip command line
An exe called by commandline is typically a console application and has a console window.

You can make the call of that via Wscript.Shell:

CODE

loShell = Createobject("wscript.shell")
loShell.Run(command,nShowWindow,.T.) 
Where nShowWindow is one of the ShowWindow constants, for example 1 = normal, 0=hide.

Or simply use Window's own Zip capabilities built into shell.application, see FAQ184-5113: How to unzip files using Shell.application

Chriss

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close