Darren - Active Billing
darren at activebilling.com.au
Mon Sep 21 20:26:33 CDT 2009
Hi Stuart This is excellent and yes simple enough for me to us e:-) I'll play around with it Many thanks for doing this for me DD -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Tuesday, 22 September 2009 10:51 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] A2003:Is a Scheduled Task Running Google is your friend. Turns out to be real simple. I found some code at http://www.bigresource.com/VB-Stop-running-process-on-remote-machine-- A6WPLr1Jnz.html#r7cwGQQdTK With a few minor mods, we end up with the following which works fine for me. I suspect you will need admin rights on the Server for it to work. Just insert your own values for server and process in CheckRunning. Option Explicit Function IsProcessRunning(strServer As String, strProcess As String) As Boolean Dim Process As Object Dim strObject As String IsProcessRunning = False strObject = "winmgmts://" & strServer For Each Process In GetObject(strObject).InstancesOf("win32_process") If UCase(Process.Name) = UCase(strProcess) Then IsProcessRunning = True Exit Function End If Next End Function Public Sub CheckRunning() Dim strComputer As String Dim strProcess As String strComputer = "LEXACORP-MOB1" strProcess = "Explorer.exe" If (IsProcessRunning(strComputer, strProcess) = True) Then Debug.Print strProcess & " " & "is running" Else Debug.Print strProcess & " " & "is Not running" End If End Sub Cheers, Stuart On 22 Sep 2009 at 10:21, Darren - Active Billing wrote: > Hi Stuart > > Thanks for the quick reply > That's way over my head that stuff > Also my access app won't be on that server either > I was hoping to pass in a known server name and a known ProcessName or ProcessID > for the Scheduled task and get back a result. > > Too optimistic me thinks <grin> > > DD > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan > Sent: Tuesday, 22 September 2009 10:11 AM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] A2003:Is a Scheduled Task Running > > If you VBA is going to be run on the Server, it's quite easy. > > You just need to identify a running process. > > There's a load of code at > http://www.answers.com/topic/enumerate-processes > > which you can just cut and paste into a VBA module. > > Comment out the "Sub Load" and call GetProcess with the name of an application. > > As written, it does a Debug.Print of the process name if it is running, you can > easily modify > that to do whatever you want. > > -- > Stuart > > > > On 22 Sep 2009 at 9:49, Darren - Active Billing wrote: > > > Hi team > > > > > > > > I need to know if a scheduled task on a server is running or not. > > > > Can this sort of thing be done via VBA? > > > > > > > > The net is full of how to set up scheduled tasks but nothing (I can find) on > how > > to see if a scheduled task is running > > > > > > > > The rationale is this > > > > We have scheduled tasks that create and upload files to servers in the U.S. > (We > > are in Australia) > > > > If the scheduled task is running and file X exists in folder Y at the same > time > > - Cool > > > > If file X in folder Y exists and the scheduled task IS NOT running then it did > > not go well > > > > > > > > I have no control whatsoever over the scheduled tasks, nor the creation of the > > file/s. > > > > In fact I have nothing to do with the activities of this server > > > > > > > > I just need to write a wrapper in Access to test the following every 20 > minutes > > or so > > > > If the file exists and the task is running - Cool - Do nothing > > > > If the file exists and the task is not running - Alert me (So I can alert > > others) > > > > The others will do all the work in resolving - I just need a simple alert > > nothing more > > > > Sounds simple eh? > > > > Many thanks in advance > > > > > > > > Darren > > > > > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com