Advertisement

04.24.2008 at 09:59AM PDT, ID: 23351026
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

After opening an application from shell is there a way to tell if that application closes
Tags: microsoft, visual basic, visual basic
Hi

I load an app from shell using the following

a = Shell(filename_veridata, vbNormalFocus)

Is there a way to tell if this has closed to then execute another command?
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: eneate
Solution Provided By: RobSampson
Participating Experts: 2
Solution Grade: A
Views: 5
Translate:
Loading Advertisement...
04.24.2008 at 10:17AM PDT, ID: 21433079

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 10:36AM PDT, ID: 21433265

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 10:38AM PDT, ID: 21433276

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.25.2008 at 05:32PM PDT, ID: 21444006

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.25.2008 at 06:00PM PDT, ID: 21444075

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.25.2008 at 07:30PM PDT, ID: 21444265

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.26.2008 at 01:58AM PDT, ID: 21444951

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.28.2008 at 12:16AM PDT, ID: 21452046

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2008 at 06:39AM PDT, ID: 21478404

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.01.2008 at 04:05PM PDT, ID: 21483467

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.03.2008 at 12:35AM PDT, ID: 21491623

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.04.2008 at 09:01PM PDT, ID: 21498082

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.05.2008 at 11:50AM PDT, ID: 21502104

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.05.2008 at 04:26PM PDT, ID: 21503792

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.05.2008 at 04:30PM PDT, ID: 21503808

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.05.2008 at 04:37PM PDT, ID: 21503831

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
04.24.2008 at 10:17AM PDT, ID: 21433079

Rank: Guru

here is a snippet that I found the only problem is that your program is halted until the program exits so I would use some threading:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
Public Sub ShellandWait(ByVal ProcessPath As String)
        Dim objProcess As System.Diagnostics.Process
        Try
            objProcess = New System.Diagnostics.Process()
            objProcess.StartInfo.FileName = ProcessPath
            objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            objProcess.Start()
 
            'Wait until the process passes back an exit code 
            objProcess.WaitForExit()
 
            'Free resources associated with this process
            objProcess.Close()
        Catch
            MessageBox.Show("Could not start process " & ProcessPath, "Error")
        End Try
    End Sub
Open in New Window
 
04.24.2008 at 10:36AM PDT, ID: 21433265

Rank: Guru

if you would not like to hault program execution there is an event underneath the process namespace
http://msdn2.microsoft.com/en-us/library/system.diagnostics.process.onexited.aspx
the method is called onexited
so after
objProcess = New System.Diagnostics.Process()
place in:
addhandler objprocess.OnExited addressof myMethod
sub mymethod

end sub
 
04.24.2008 at 10:38AM PDT, ID: 21433276
Thanks, what do I define objectprocess as?
 
04.25.2008 at 05:32PM PDT, ID: 21444006

Rank: Genius

Hi, if you add a reference to your code to Microsoft Scripting Runtime (via Tools --> References), you can use this code:

Set objShell = CreateObject("WScript.Shell")
objShell.Run filename_veridata, vbNormalFocus, True

It is the True there that makes the code wait for the program to finish before continuing.

Regards,

Rob.
 
04.25.2008 at 06:00PM PDT, ID: 21444075
That looks cool, Thanks Rob

what do I enter for wscript, is this the path name?? I've tried as is bot nothing happens?
 
04.25.2008 at 07:30PM PDT, ID: 21444265

Rank: Genius

It should work as
Set objShell = CreateObject("WScript.Shell")

what does filename_veridata translate to?

It needs to be a command, for example, something like
filename_veridata = "cmd /c mybatchprocess.bat"
objShell.Run filename_veridata, 1, True

As long as you've added the reference to Microsoft Scripting Runtime, that should work.

Regards,

Rob.
 
04.26.2008 at 01:58AM PDT, ID: 21444951
Hi

filename_veridata is the full path of the exe for exmaple c:\program files\veri.exe

How would I modify this to make it a command line?

Scripting runtime is added, I already use it for other apps in the program.
 
04.28.2008 at 12:16AM PDT, ID: 21452046

Rank: Genius

OK, would that be *only* the program's executable, or the executable, plus a parameter?  For example, is filename_veridata defined as:
filename_veridata = "C:\Program Files\Veri.exe"

or
filename_veridata = """C:\Program Files\Veri.exe"" ""myparameter"""

In any case, the program should be able to be executed from the command line, so just use:

filename_veridata = """C:\Program Files\Veri.exe"" ""myparameter"""
Set objShell = CreateObject("WScript.Shell")
strCommand = "cmd /c " & filename_veridata
objShell.Run strCommand, 1, True

Regards,

Rob.
 
05.01.2008 at 06:39AM PDT, ID: 21478404
Hi

sorry for the late response I've been away with work for a few days.

The filename isn't passed as ""c:\gram files\veri.exe"" as it is passed as a varoiable and the path is read from the system registry. it would be the path name without the parameter.

I have tried some variations on the above but no success so far.....

 
05.01.2008 at 04:05PM PDT, ID: 21483467

Rank: Genius

OK, we'll try a different way.

I understand that the file path is read from the registry, so just ignore my assignment of the variable, and replace it with your version that is read from the registry.

Regards,

Rob.
1:
2:
3:
4:
5:
6:
7:
filename_veridata = "c:\windows\NOTEPAD.EXE"
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec(filename_veridata)
While objExec.Status = 0
	WScript.Sleep 100
Wend
MsgBox filename_veridata & " has now ended with exit code " & objExec.Status
Open in New Window
 
05.03.2008 at 12:35AM PDT, ID: 21491623
Hi
Ok that opens the app great, but doesn't seem to know when it finishes. As this app runs with other software I hide all the open forms just before this software loads, I then need them to re show after it has cloased. I created a function as boolean with your code, and the forms were hidden and the apps runs fune, but after it exits nothing happens. I used


    'hide all active windows
   
   For i = Forms.count - 1 To 0 Step -1
   
     Forms(i).hide
   Next

If open_idem = True Then  'this is the shell call to load the app

    'hide all active windows
   
   For i = Forms.count - 1 To 0 Step -1
   
     Forms(i).Show
   Next
   
   End If

Thanks
 
05.04.2008 at 09:01PM PDT, ID: 21498082

Rank: Genius

Hi, I'm thinking you'll need to try something like the code below.

Make sure your project (Office VBA or VB6) has a reference to Microsoft Scripting Runtime.

Regards,

Rob.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
For i = Forms.count - 1 To 0 Step -1
	Forms(i).hide
Next
'MsgBox "Forms hidden."
 
If open_idem = True Then  'this is the shell call to load the app
	'show all active windows
	For i = Forms.count - 1 To 0 Step -1
		Forms(i).Show
	Next
	'MsgBox "Forms visible."
End If
   
Function open_idem
	filename_veridata = "c:\windows\NOTEPAD.EXE"
	Set objShell = CreateObject("WScript.Shell")
	Set objExec = objShell.Exec(filename_veridata)
	While objExec.Status = 0
		WScript.Sleep 100
	Wend
	'MsgBox filename_veridata & " has now ended with exit code " & objExec.Status
	open_idem = True
End Function
Open in New Window
 
05.05.2008 at 11:50AM PDT, ID: 21502104
Hi
Thanks for replying, I now get object now found error for the line

WScript.Sleep 100

I have referenced to microsft scripting runtime, but there must be a reference or declaration missing somewhere??
 
05.05.2008 at 04:26PM PDT, ID: 21503792

Rank: Genius

Are you using VBA in Office programs?

Instead of the WScript.Sleep statements, try
Application.Wait(Now + TimeValue("00:00:01"))

Regards,

Rob.
 
05.05.2008 at 04:30PM PDT, ID: 21503808
No I'm not using any office programs just vb 6 not linked to office at all.
Thanks
 
05.05.2008 at 04:37PM PDT, ID: 21503831

Rank: Genius

OK, I've added the Sleep API method here.

Regards,

Rob.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
 
For i = Forms.count - 1 To 0 Step -1
	Forms(i).hide
Next
'MsgBox "Forms hidden."
 
If open_idem = True Then  'this is the shell call to load the app
	'show all active windows
	For i = Forms.count - 1 To 0 Step -1
		Forms(i).Show
	Next
	'MsgBox "Forms visible."
End If
   
Function open_idem
	filename_veridata = "c:\windows\NOTEPAD.EXE"
	Set objShell = CreateObject("WScript.Shell")
	Set objExec = objShell.Exec(filename_veridata)
	While objExec.Status = 0
	    Sleep 100
	Wend
	'MsgBox filename_veridata & " has now ended with exit code " & objExec.Status
	open_idem = True
End Function
Open in New Window
Accepted Solution
 
 
05.06.2008 at 03:42PM PDT, ID: 21511640
No problem. Thanks for the grade.

Regards,

Rob.
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628