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,065 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
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…

747 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

8 Experts available now in Live!

Get 1:1 Help Now