473,769 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to call a VB6 application from Windows Service Application

DH
I hope this is a right place to post my question

I'm working on a Windows service application with VB.net. The purpose is to let the service application as a monitor to periodically check a launching flag file. If the flag was found the service will trigger to run a finance calculating program (VMPE4SRVAPP.ex e, a VB 6.0/Access application but without windows interface). I added a Process and two Timers on the Service to do checking and launching jobs (Process1.Start to call VMPE4SRVAPP.exe ) . Please see the following code

Imports System.ServiceP roces

Public Class MyNewServic
Inherits System.ServiceP rocess.ServiceB as

Protected Overrides Sub OnStart(ByVal args() As String

EventLog1.Write Entry("In OnStart"
Timer2.Enabled = Tru

End Su

Protected Overrides Sub OnStop(

EventLog1.Write Entry("In OnStop."

End Su

Private Sub Timer1_Elapsed( ByVal sender As System.Object, ByVal e As System.Timers.E lapsedEventArgs ) Handles Timer1.Elapse

Timer1.Enabled = Fals

Dim myProcess As New Proces

Process1.StartI nfo.FileName = "C:\VMPE4SRVAPP \VMPE4SRVAPP.ex e
Process1.StartI nfo.Arguments = "vm3retail
Process1.StartI nfo.WorkingDire ctory = "C:\VMPE4SR VAPP
Process1.StartI nfo.RedirectSta ndardOutput = Fals
Process1.StartI nfo.WindowStyle = ProcessWindowSt yle.Minimize
Process1.Start(

Timer2.Enabled = Tru

End Su

Private Sub Timer2_Elapsed( ByVal sender As System.Object, ByVal e As System.Timers.E lapsedEventArgs ) Handles Timer2.Elapse

If Len(Dir("C:\tem p\LaunchingFlag .ok")) > 0 The
Timer2.Enabled = Fals
Kill("C:\temp\L auchingFlag.ok"
Timer1.Enabled = Tru
End I

End Su

End Clas

I installed the service. When I started it, I could see (from windows explorer) a MDB file was generated and its size indicated that data was loaded. I also saw VMPE4SRVAPP.exe was displayed on Processes tab of Windows Task Manager. However the process stayed on the tab forever. When I tried to open the MDB file, I got "Access denied... It is already being in use". When I tried to copy the MDB I got "Sharing violation".
I can only access the MDDB file after I re-boot my PC
What's wrong with my code? Or is there a better way to call my VB 6.0 Calc application in Windows Service? Can I use Shell in a Service instead of Process (If I can how to coding them)

Thanks for your help

Jul 21 '05 #1
3 3034
MW
DH,

You can check if the process has completed using the HasExited property.

It is possible that something is preventing your VB6 process from
completing? Are there any message boxes in the application that might be
holding up your VB6 app? Since you cannot access the UI you may not know
about it. Possibly a simple way to find out is to execute the exe externally
with the same arguments and see if the application terminates in the end.

Also since this process is starting from a service, I would set the
CreateNoWindow = True and the WindowStyle to hidden, because there is no
user input to the UI of the process.

You can shell execute if you set ProcessStartInf o.UseShellExecu te to True.
However if you do that you will not be able to redirect output or error
streams in your service application.

HTH
Wazir
Jul 21 '05 #2
DH
Hi Wazir

Good start point! I will try to run my VB6.0 exe externally to see if any MsgBox hold it to end the job. You mentioned "CreateNoWindow "/"WindowStyl e". Are they properties of Process (I will check them out later afternoon)

DH
Jul 21 '05 #3
MW
DH,

If you have any message boxes (or anything else that may require user input)
then the process will not complete inside the service. It will be a good
idea to remove them if you can (or allowed to). Also when you test the app
externally make sure the arguments are the same as you gave in the windows
service.

The properties belong to the Process.StartIn fo object

Dim oProcessStartIn fo as new ProcessStartInf o()
Dim oProcess as Process

With oProcessStartIn fo
.FileName = [Filename]
.Arguments = [Arguments]
.UseShellExecut e = False
.CreateNoWindow = True
End With
oProcess = Process.Start(o ProcessStartInf o)

Regards,
Wazir
"DH" <an*******@disc ussions.microso ft.com> wrote in message
news:4E******** *************** ***********@mic rosoft.com...
Hi Wazir.

Good start point! I will try to run my VB6.0 exe externally to see if any MsgBox hold it to end the job. You mentioned "CreateNoWindow "/"WindowStyl e".
Are they properties of Process (I will check them out later afternoon)?
DH

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
8205
by: Clint | last post by:
Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that does nothing but return "true" (this will obviously change once the program's fully built to actually do something, but for testing, it works). The only code I added to the service is below:
0
1237
by: bs | last post by:
Hi, I am currently having a problem calling a web service that is secured using a digital certificate. I set up a Windows application to make a call to the service and it works fine. However when I make a call from my ASP.NET page it fails with "System.Net.WebException: The request failed with HTTP status 403: Forbidden". The code that I am using to make the call in both instances is: MyWebService myService = new MyWebService();
2
4100
by: elora_c | last post by:
I'm making a call to a webservice from my ASP.NET page. The web application has anonymous access turned off and Integrated Windows auth turned on. The web.config has <identity impersonate=true>. I set the credentials of the web service proxy to the DefaultCredentials. Right before I make the call, I print out the WindowsIdentity, and it is showing the right identity. So I know the web application is authenticating properly. However,...
3
507
by: DH | last post by:
I hope this is a right place to post my question I'm working on a Windows service application with VB.net. The purpose is to let the service application as a monitor to periodically check a launching flag file. If the flag was found the service will trigger to run a finance calculating program (VMPE4SRVAPP.exe, a VB 6.0/Access application but without windows interface). I added a Process and two Timers on the Service to do checking and...
0
2014
by: Griff | last post by:
Overview When the first call to our Web Service causes an exception, the Web Service caches that user's credentials for its life time. Details We have a Web Service which uses Windows Authentication. Within the Web Service we look at the current username and check which user Groups it belongs to.
3
16228
by: BLUE | last post by:
I've to call 2 web method from time to time so that the web service will do cleanup and sync jobs on a database. These methods can be called once every X days where X >= Y for the sync method and X >= Z Y for the cleanup method with Y and Z specified by the user in the app.config file. Is it best to create a web service client app and schedule it with Windows Scheduler or to create a web service client Windows Service that will use a...
3
4682
by: =?Utf-8?B?Y2hlbmRyaWNrcw==?= | last post by:
I have a C# winforms application that makes periodic web service calls in background thread to my web service server. These calls work fine almost all the time but on rare occassions the web service method call will never return and the entire application will freeze, even though the call is being made on its own background thread, not the main UI thread. Does anyone know any reason why a particular web service method call would cause my...
2
5570
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the serialization settings for the build handled the initial slows we encountered when invoking the web service. Since that time, we ported the original VB.net code over to C# - this was done to make it cleaner easier to include the project in the rest of...
5
6208
by: Stefano Tonello | last post by:
Hi all, I need to call windows' "open with" dialog from my C# windows form application. After the user selects application, control must return to me (I have to launch directly the process). I found this solution: http://www.codeproject.com/KB/shell/openwith.aspx but it's not good for me since it will execute the process directly.
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.