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,066 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

18 Experts available now in Live!

Get 1:1 Help Now