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,079 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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