DWUTKA at marlow.com
DWUTKA at marlow.com
Thu Aug 18 10:58:03 CDT 2005
LOL. I just do so much tech support outside of programming, that when it comes to coding AND Windows related stuff, I have a pretty good grasp on it. Heck, I have more VB 6.0 NT services in place here at work, then I have Access .mdb's being used as a front end. (By a factor of close to 10, I'm sure....) Drew -----Original Message----- From: John W. Colby [mailto:jwcolby at colbyconsulting.com] Sent: Thursday, August 18, 2005 10:59 AM To: dba-vb at databaseadvisors.com Subject: RE: [dba-VB] Running an app from a service Right you are. I read that somewhere, but forgot about it. And Voila, it opens Notepad visible. OK, maybe YOU are the master... John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of DWUTKA at marlow.com Sent: Thursday, August 18, 2005 11:37 AM To: dba-vb at databaseadvisors.com Subject: RE: [dba-VB] Running an app from a service It's not visible because NT Services do not interact with the desktop. You can set a service to be interactive though. Haven't done an NT service in .Net, but when the service is registered with the OS, just go into the service properties, and the Log On tab, and put a checkbox in 'Allow service to interact with desktop'. Just a note, if you are using a specific account to run the service as (which is required if you are going to try and hit network resources that require authentication), this option will not be available, since it is only for running as the Local System account. Drew -----Original Message----- From: John W. Colby [mailto:jwcolby at colbyconsulting.com] Sent: Thursday, August 18, 2005 10:32 AM To: 'Access Developers discussion and problem solving'; VBA Subject: [dba-VB] Running an app from a service I have created a service using VB.Net. The service can be registered, once registered I can start it etc. It runs, with a timer tick writing a log to application.log so I can see that the timer tick is happening. Once I got that working I went looking for how to run an external application from the service. The code I found looks like: Dim p As System.Diagnostics.Process p = System.Diagnostics.Process.Start("notepad.exe", "sample.txt") p.WaitForExit() A couple of things. Notepad is running, it can bee seen as a process in Task Manager, but it is not visible, and it has not created sample.txt AFAICT. I found other code (in C# unfortunately) that looks something like: Dim p As System.Diagnostics.Process Dim psi As System.Diagnostics.ProcessStartInfo psi = System.Diagnostics.ProcessStartInfo psi.FileName = "notepad.exe" psi.Arguments = "sample.txt" psi.WorkingDirectory = "x:\Luminex" psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized p = System.Diagnostics.Process.Start(psi) p.WaitForExit() PSI appears to be a structure for loading properties that P will use. Even when done this way, the notepad is not visible. Furthermore, in either case the code does not wait... Or maybe the timer spawns a thread and will fire again spawning another thread. In other words, next timer tick I get another instance of Notepad. However... If I place a line of code that writes to the log file before and after the call to the sub that opens notebook, the line before the call to open the notepad does log, the line after does not log. So, I do not understand all that I know about this stuff. If anyone has any ideas how to make the process visible I would appreciate it. I also do need the code not run again until the app shuts down. I think I can just shut off the timer so I can handle it that way if the timer will fire again even if the p.WaitFor() is in place. Any comments? Has anyone done this? John W. Colby www.ColbyConsulting.com Contribute your unused CPU cycles to a good cause: http://folding.stanford.edu/ _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com