[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ShellExecute()

Posted on 2002-07-01
5
Medium Priority
?
836 Views
Last Modified: 2008-02-26
==========================
VB.NET
Windows 2000
==========================

(Though I'm using VB.NET, I think I would have this same problem with VB6, and this forum gets so much more traffic...so I'm posting the question here...)

I guess I've never called ShellExecute() with command-line parameters, because I'm sure not able to do so successfully today.

I need to call an executable with a (possibly long) list of switches and parameters.  Here's my code at the moment:

======START CODE======
   Public Const SW_SHOWDEFAULT As Integer = 10
   Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
   ( _
   ByVal hWnd As Long, _
   ByVal lpOperation As String, _
   ByVal lpFile As String, _
   ByVal lpParameters As String, _
   ByVal lpDirectory As String, _
   ByVal nShowCmd As Long _
   ) _
   As Long
   ...
   Dim nTemp As Long
   Dim sEXEPath As String
   Dim sFilePath As String
   ...
   sEXEPath = "C:\dev\XML\XMILL\win32\XMILL.EXE"
   sFilePath = "C:\~RexDB.XML"

   nTemp = ShellExecute(0, "open", sEXEPath, sFilePath, "", SW_SHOWDEFAULT)

======END CODE======

This .EXE always produces an output file at the path of the file it's provided ("sFilePath" above).  The absence of this file tells me it's not working.  It works just fine through the DOS window ("C:\dev\XML\XMILL\win32\XMILL.EXE C:\~RexDB.XML").

How do I call this from VB.NET?  I've tried several different things, but no luck thus far.

Thanks

0
Comment
Question by:bryker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 400 total points
ID: 7122698
Why are you using shellexecute instead of simply shell?  ShellExecute opens a file with it's associated exe.  shell simply executes a command as if it was at the command line (almost.)
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 7122725
have you looked at the Shell function (see the help file for "Shell function").
0
 

Author Comment

by:bryker
ID: 7122803
Mr. Hewson:

Works great--thanks for the help.  Don't know why I wasn't using Shell.

By the way, what do you mean by "as if it was at the command line (almost)"?  Does it have some constraints, or things it won't do?(piping output, switches, something like that?)
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 7123018
>piping output,

When you try to use it to redirect StdOut using ">" to a file, Shell (and associated win32 api methods) will not perform the redirect.  There are ways around it however, if it is necessary to redirect from the command line.
0
 

Author Comment

by:bryker
ID: 7123130
Just wondering.  Thanks again.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 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