Solved

In VB need to get processId from Wscript.Shell or need to bring focus to window that I launch from Shell("some.exe")

Posted on 2004-08-16
8
1,071 Views
Last Modified: 2012-08-14
In the VB exe I am making I launch an exe and want to wait for it to return.   However in the code that waits for the exe to finish running uses a processID.  My problem is that I when i use the command Shell("nameofexe.exe") it launches the exe but does not show the window.  (It is a minimized window)  I then tried using Wscipt since I knew this would show the window.

Set WshShell = CreateObject("WScript.Shell")
installerId = WshShell.Run(".\Installer.exe")  

However this presented the problem that WshShell.Run(".\Installer.exe") does not return a process Id.  So if anyone can tell me how to either get the processId from Wscript.run or tell me how to make the window not be minimized when i run:

installerId = Shell(".\Installer.exe")

i would be very grateful and reward them the points.  Thanks in advance.
0
Comment
Question by:jstreb
  • 4
  • 2
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11811635
What are you trying to accomplish here with the WshShell?  You can use this instead:

Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.Arguments = myargumentstring
p.StartInfo.WorkingDirectory = myworkdirectorystring
p.StartInfo.FileName = "C:\myprogram"
p.Start
p.WaitForExit()

Bob
0
 

Author Comment

by:jstreb
ID: 11812197
Basically I need to run through a seperate installer and make sure that that program is installed first before I proceed with anything else in my program.  All I want to do is launch that .exe and show the install wizard to the user and then proceed with my exe when they have finished with the install wizard.

I tried using your code you posted but I got a compile error of: = expected for the line p.WaitForExit().  I am using VB 6.0, don't know if that could be the cause.  Thanks though.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11812238
Well, this is the VB.NET topic area.  You might want to post a free question in Community Support and ask for this question to be moved to http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/.

Community Support:
http://www.experts-exchange.com/Community_Support/

Bob
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:jstreb
ID: 11813919
Well i found the an answer for those who are curious in the future.  The shell command can take in arguments to determine focus and size.  I ended up using the command:

installerId = Shell(".\Installer.exe", vbNormalFocus) and this did the trick.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11814043
Good, I'm glad you found your answer.

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11814052
You can post a free question in the Community Support topic area and ask them to PAQ this question and refund your points.

Bob
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 12143509
Submitted to PAQ with no points refunded (of 125)

DarthMod
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
VB.net Move a class from Solution Items to a project 2 33
SqlServer no dupes 25 38
Iteration Help (Asp.net VB) 5 24
Access/Visual Basic Question 3 25
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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