Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Check If A Service Is Running


I need to check if a service (specifically SQL Server) is running. I am trying to attach a databse but need to be sure the service is running. I can check the registry to make sure the server is installed but am not quite sure how to check if it is currently running. Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Can I Check Does The Service Running On Windows?
Hi All,
Does any API or method can I use to check is there any service currently running in service named "xxx"(Service name).

Thanks
Samuel

Running As Application Vs. Running As A Service
How do I tell an existing application to run as a service over there on the taskbar next to the system time? Would I be introducing any limitations by converting a program from running as a program to a service? Thank you.

How To Check If The Excel Program Is Running Before Updating It And If It's Running, How To Close It
How to check if the excel program is running before updating it and if it's running, how to close it and do update? - thanks

Timer To Check Process Is Running If Not Running Start It
Hi,
I need some code that checks if a process/application is running, then if it is goto timer and wait say 10 mins, if it isnt then start application then goto timer 10mins.

1)Open vb form
2)Puts list of applications that are running (bit like task manager) in text box e.g. applist

3)Click start button
4)Refreshes list of applications in text box e.g. applist
5)then runs check to see if application is running

6)If a certain application is not running (in this case its vbeng1) then start it then goto to timer which restarts this check process.

7)If the certain application is running then goto to timer which restarts this check process.


Also need a stop button which stops this process and maybe a refresh button that refreshes the running application list.

Please can you help me thanks in advance <3
zain

Running As A Service
How could I make my program run as a service, make it run on startup and yeah, well you guys know what a service is. I'm running XP Home, and yes, i do know there are programs out there (firedaemon) which can set it up, but I was wondering if my program could just configure its self to run as a service.

Running VB As A Service?
Hello Again,

I am looking for input on running Visual Basic as a service. I have done some research on this and I found a microsoft page that gives a control (NTSRV.OCX) to use for this. But it basically says microsoft does not reccomend running Visual Basic as a service even with Ntsrv.ocx.
The Article is Below:
http://support.microsoft.com/directo...EN-US;Q175948&

There so many advantages to running an operations type application as a service. I am still tempted to try it anyway.

Does anyone have experience with running Visual Basic as a service? Did you use nstrv? What is your experience with running Visual Basic as a service?

Thanks,
Beth Barja

Is Service Running?
Is there any way to tell if a windows XP or NT service is running through VB?

Thanks!

VB EXE Running As A Service
Help,

I have a vb application which will run on an NT 2000 server, the app runs 24/7 and polls several directories for csv file coming in and then processes then (upload to a database). I need to run the app as a service and not just kick it off on the desktop but I have read on the microsoft site that you can not run a vb exe as a service. Does anyone know how I can run my vb app as a service.

Thanks for your help,

Chris

Running As A Service
How would it be possible to run my VB App as a Win2000/XP background service? Without using any third-party software.

Running As A Service?!?
How do I make my VB App so therefore it loads up when I boot the computer and keeps running even if the user logs on and off...?!?

For e.g. I want it to be running non-stop even when the user logs off and it stays in the "Novell Client Logon Window"?!?

Running As Service?
Hello!

Is there any way to check if my app is running as a service or not?

App Running As Os Service?
I received one additional piece of information which may help
(doesn't help me, but maybe it will help someone help me): someone
suggested that the application, or a part of it, begins running as a
service of the operating system. If this sounds plausible, where does
the problem likely originate? Is it some part of the program code, or
some program code that is not present (the app. has nothing in it that
attempts to identify its environment), or maybe something in the
project properties?

Thanks for any info.

Here is the relevant part of my original post:
I have a vb6 application which may have been started on Windows95
using an earlier vb version, definitely updated on Windows98(inc. SP
5). It is deployed on a machine running WindowsXP, and in this
environment the user can close the program, yet it (or some remnant of
it) remains listed in the Task Manager. This doesn't happen every time
user closes the program, and without looking at Task Manager it
appears the program is completely gone--no minimized windows in the
task bar, no error or warning messages.

Running VB As A Service
Can VB be run as a service ( possibly with a tray icon )

if so would I just set it up as a module and no form

any help would be great


Thanks

To Know Whether A Service Is Running
Hai Gurus,

I want to findout whether a service "RPCSS.EXE" is running or not. I would wait till the service is running, then I want to start my application.

How do I know whether the service is running?

Pls give your suggestion

Thanking you in anticipation

Ravi

Running As NT Service
How to make an application running as service in Windows NT?

Windows Service Running
How can I verify if a Windows Service such as Telnet is up and running on a remote server using a VB Script?

Com+ Application Running As Service.
I have a DLL which is registered in COM+ on an XP machine. It has been set to run as an NT Service with a Domain user ID. The service runs fine for some hours, then the service stops. The service cannot be restarted without retyping the password. (the machine is kept without any user logged in) Does any body know the reason for this ?

Please Help - Checking If A Service Is Running...?
Hello,

Does anyone know of a Windows API function or some other mechanism that would check if a particular service is running on Windows NT?

I need to write a utility that will check if a service is running, and if not, it will need to start it... Please help!

Thanks!
Mark.

Printing While Running As A Service
I am running a VB 6.0 app as a service on a windows 2000 box. This application is supposed to print out letters. I am using the ntservice control on my form, and as far as the service goes everything seems to be fine.

The problem is, VB cannot access the printer object.

I even tried putting together a simple app that just cycles through the printer collection and logs the printer information. Works fine as an exe run from windows, but once again, when run as a service, there is no access to the printer collection; nothing at all.

Any suggestions would be helpful!

Running My Application As A Service.
Hello I want to run my application in the background as a windows service.
What I mean is I dont want it to appear in the Program list in taskmanager but only in the process list.

How Do I Detect A Running Service In VB6?
I want to know how do I detect a running service?

e.g
If iexplorer.exe is running how do i detect it.

Thank you for your time and help.

How Do I Know If I'm Running Vb 6 With Service Pack 5?
when i go to help | about, it only says i'm running version 6.0.8169. how can i figure out if i have already installed service pack 5 for vb 6?

Running VB Application As Service
Can someone help me in running my VB application's exe as windows service. so that it can't be killed from task manager.

I want to run it on both XP and vista as a service.

Need help badly.
thanks in advance,
Ruhii

Could Be Tricky.. Running A Vb App As A Service
Hey all,

I am looking to run my vbapp as a windows service in the background. Basically I need to install it on a system and have it loaded in the startup, this is all fine and well once the user has logged in, however I need to consider the possibility of a power failure or system reboot and I need the app to run as a background service, therefore it will be running without anyone having to physically login to windows. Can this be done?

Thanx

Problem With VB App Running As Service
I have a VB app that uses a timer to run a fuinction every 60 secs.

Within that function I have some loggin code so I can see when the function is correctly processed.

I used Eltima Application As Service (cos I was lazy and needed some quick way) to get it running as a windows service on my Win2K production server.

However every week or so it stops functioning correctly and also stops writing to my error log.

Is there some issue with using an app with a timer as a service? Any ideas how I can investigate/debug this?!

I could upgrade to eltima v2 as this is upposed to restart stopped services, but not sure whether this would help as I'm not sure if my service is actually stopped, or whether its the VB exe that has the problem.

Any help in investigating this much appreciated!!
Kester

Running As System Service
Me again.
Now I am looking into making a program run as system service. IM guessing its just a ton of API?

Running As Service - Resolved
How do I run some existing applications of mine done in VB6 as a service.

Currently they run hidden with a small icon in the bottom right to show them up but I need to now run them as a service.

I cant seem to find anything that makes sense to me (I am a bit thick!)

Has anyone got any code or programs that does it?

Printing While Running As A Service
I am running a VB 6.0 app as a service on a windows 2000 box. This application is supposed to print out letters. I am using the ntservice control on my form, and as far as the service goes everything seems to be fine.

The problem is, VB cannot access the printer object.

I even tried putting together a simple app that just cycles through the printer collection and logs the printer information. Works fine as an exe run from windows, but once again, when run as a service, there is no access to the printer collection; nothing at all.

Any suggestions would be helpful!

Running A VB 6 Program As A Service.
I have a program (VB6 exe) that I need to execute daily on a Windows 2000 server with no one logged in.

I have 2 questions.

1. What do I need to do - if anything - to allow this program to run as a service?

2. Can I schedule services using, say, windows task scheduler or some other admin tool (or API) or would the program itself just have to keep running continuously and checking whether it was time to do its stuff?

Service Running As Trayicon
I've done application and put it to run as a service. I understand that services run in background, don't have GUI etc., but I really need it to run as trayicon immediately when it is activated, so that I can choose among some settings, shut it down and so on.
I know how to code that, but I don't now how to implement that to service.

Thanx for anykind of info in advance !

Detecting A Running NT Service...
I need my VB app to detect whether an NT service is running or not, does anyone know of urls where I might find this information, or could anyone here point me in the right direction for doing this?

Any help would be appreciated.

Running A VBS Script From Within A Web Service
Hi, first off I'm very new to Visual Basic, I'm trying my best to figure out how I can run a Web Service using VB so that we can query our windows machines from Linux at my work.

So far I have a simple little script that receives data and is then supposed to execute a VBS script using this data for the parameters, but I can't find any good documentation on how to execute a script.

The script is adsutil.vbs and we normally use it from within a BAT script ("%WINDIR%system32iisweb.vbs /create c:Temp "Template" /d %DOMAIN% /dontstart")

Can anyone give me a pointer in the right direction as to how I would execute this script from within a VB Web Service?

Thanks in advance!

Permissions On A Service Running A VB App
Hi There all,

Some more help from you guys please. I have a system service that spawns a VB 6 exe every hour at 30 minutes past the hour on a WIndows 2000 advanced server PC.

The exe uses a system ODBC connection to communicate with an Access database on another server on the LAN. When I setup the ODBC conenction, I used the full UNC name to the server and had to connect as another user on a domain to enable me to see the Access database, on the server.

If I run this VB app from the command line, it works fine. However when the system service tries to run it, I get an Microsoft Access ODBC driver error saying that the file is not valid.

I am pretty sure that this is down to permissions. I have tried to change the system service. I have tried to get the system service to run as the user that I specified when trying to create the ODBC connection (as opposed to localsystem) but it says that the user name is unknown!!

Any guidence that you guys can give me would be much appreciated.

Thanks.


Shutting Down A VB App Running As A Service
I have a VB application that is running as a Service on Windows 2000. When the service is stopped, I don't think all the resources are being freed up properly. Is there a way to receive a notification that the service is being shut down so that the VB application can shut down gracefully? I noticed that on other posts, they talk about shutting down a form, or clicking on a button, etc, however, I don't have any forms to handle this. Any help is greatly appreciated.
Thanks.

Printing While Running As A Service
I am running a VB 6.0 app as a service on a windows 2000 box. This application is supposed to print out letters. I am using the ntservice control on my form, and as far as the service goes everything seems to be fine.

The problem is, VB cannot access the printer object.

I even tried putting together a simple app that just cycles through the printer collection and logs the printer information. Works fine as an exe run from windows, but once again, when run as a service, there is no access to the printer collection; nothing at all.

Any suggestions would be helpful!

Running Vb6 Program As A Service
is this possible in windows 2003? I need to scan a drive every hour and copy files to a location if they exist, i'd prefer to use vb but i dont think its possible, if it is, has anybody done it or got any advice?


many thanks

Running Service On A Remote Server
hi,

I have a service written in VB which resides on a remote server.

When i am logged onto the remote machine via rdp or mstsc (to get the console) the software runs correctly.

When i am not logged on the service does not run correctly and hangs waiting for user interaction to press a button on the dialog box.

what happens is that the service prompts with a dialog box to open,save or cancel, the service should then choose save and carry on, this happens when im logged on.

I thing the problem could be that the dialog is assumed to to be runnning in the background, and we need it in the foreround to automatically detect and press save.

how can it get it in the foreground or to think it is there ?

Getting Windows User While Running App As Service
Hi,

I have always been able to get the current Windows XP user using API. But now I have changed my app to run as a system service and it always returns SYSTEM as the current user. Does anyone know how to get the current user logged on even with my app as a system service? Does it write to the registry the current user logged on so i can just read that possibly?

Thanks!

Running A Program As A Win2k/xp Service?
Can you walk me through running my proggie as a service? I just don't understand it.

Logging Off Esarting VB App When Running As Service
Hi,

I have an VB app running as a service which connects to another app via TCPIP (vb app is receiver) and is set to interact with desktop. When user logs off PC i have VB app set to run as normal meaning the socket is never closed which i have set in the form unload which is called when user logs off. Problems is when PC restarts or shutsdown the VB app TCPIP connections never closes so when VB app starts up via NT Service the TCPIP connection is lost or is not connected to sender. This is because in the form unload i chose not to close connection to accomendate user logging off. To establish TCPIP connection you have to restart VB app which would defeate the purpose of running as a service. Is their a way of getting a windows message to VB app when PC is restarting or shutting down or logging off so i can program accordingly. If user logs off run as normal. If PC shutsdown or restarts close socket connection thus allowing it to recconect when PC starts up again. Hopefully this made sense and any help or insight would be appreciated. Thanks for you time.

Icon Behaviour With VB App Running As NT Service
Hello,

My question concerns convincing my System Tray icon to behave elegantly.

I have written a VB6 app that I need to run as a NT Service; as such, I've made use of the Microsoft NT Service Control Component provided by Ntsrv.ocx. This approach has worked like a charm and I'm very happy with the results except for one thing: If I log out and back in again my service is still running, and that's all well and good, but my application's icon no longer appears in the System Tray.

I have set up a timer firing every second that calls Shell_NotifyIcon and of course this works. However, I don't want to have this timer continuing to operate once the icon is successfully added to the tray. Now you might say I should disable the timer when Shell_NotifyIcon returns <> 0 and you'd be right, except for the folowing little problem.

The Problem: My service starts manually by design so of course when the app adds the icon to the tray on startup it works just fine, but I can't disable my timer at this point because I'll need it running if a user logs out and back in again. I could use a "hook" to catch messages like "WM_QUERYENDSESSION" and start the timer, but again I don't want the thing running the entire time someone is logged out.

So I believe I need a way of knowing when someone is logging back in, I could start my timer at this point and then disable it when Shell_NotifyIcon returns successfully.

If anyone out there has had some experience with these issues, or has anything insightful for me I'd sure appreciate it.

Oh, this is my first post, so sorry if I was too long-winded.

Thanks in advance!

How To Detect An Application Or An Service Is Running?
Hi,

Do anyone know how to detect an application or a service is running(locked)in VB?

Thank you for your help in advance.

Tlim

Check Service State
Hello everyone...

Can anyone help me with the code for a quick utility that will check to see if MSSQLSERVER is running and if it is not, keep checking until it is and then launch another program.

I am having the toughest time finding out this information.

Thanks
gb

Check The Status Of A Service Using Vb
i have a vb app and i need to check to see if the service is running or not. if the service is running the app should continue if not it should send a command to start the serviec. can any one help.

Thanks,
Thomas

Admin Check With A Service...
VB Code:
Private Sub NTadmin_Timer()    If Form1.Visible = False Then        If CBool(IsNTAdmin(ByVal 0&, ByVal 0&)) = True Then            Form1.Visible = True            App.TaskVisible = True        End If    End If    If Form1.Visible = True Then        If CBool(IsNTAdmin(ByVal 0&, ByVal 0&)) = False Then            Form1.Visible = False            App.TaskVisible = False        End If    End IfEnd Sub


i use that every second to check if an admin is logged in with this service....

if i log in with my admin account on XP, it will show the program (programs defaults are hidden)

but if i log in as a guest after logged in as admin the program will not hide!

big problem, cant have guest accounts messin with the program....

Use Service To Check If Anyone Has Logged In
I ahve a service running, now as I understand it, services run before you log in.
How would I run a function only once a user has logged in and then only the once.
Iam missing somthing easy...think i should give up for the day lol

}...the bane of my life!
http://www.fuzzyd.co.uk

Interprocess Communication Between Service And Running ActiveX EXE
Hi all,

I am having trouble with interprocess communication between a Service and my ActiveX EXE...

Basically, there is a Windows Service that I want to integrate with my ActiveEXE. The Service provides a VBScript interface for extensions. My ActiveX EXE is running on the desktop and has a public multiuse class which registers itself in the ROT. What I am trying to achieve is to communicate between the Service and the running ActiveX EXE without starting a new instance of the ActiveX EXE (hence the ROT entry).

Testing the ROT entry works fine using another VB app and get a reference to my ActiveX EXE class via GetObject function. So, if my ActiveX EXE Server is not running a new one is not created and if it is it gets a reference to the existing one.

So I wrote a small Vbscript plugin to do a GetObject on my ActiveX EXE from the Service.

This is where it gets ugly.

Basically the VBScript can not do a GetObject because the two processes (Service and ActiveX EXE) are running in different namespaces:
The Service is running a LocalSystem
The ActiveX EXE is obviously running as InteractiveUser (whoever that maybe)

So to try and bypass this security problem I have created a proxy COM object (ActiveX EXE again) which gets created by the VBScript with CreateObject. This I do with DCOM config and set it to run as the interactive user so I 'jumps' domains to the same domain as my ActiveX EXE Server.

This seems to work pretty ok but (there is always a but) the problem I am facing now is distributing this set of ActiveX EXEs (the Proxy and the Server).

I know of no easy way (and automatic) to create an install or configure the Proxy to run as Interactive.

Things I have been looking into have been the [navy]HKEY_CLASSES_ROOTAppID[/navy] where the [green]RunAs[/green] defines the setting I want to change. I also suspect using something like InstallShield could also help (I am assuming). The problem with this is that if I want to distribute a new EXE for the Proxy (an update), I will need to distribute logic to manage this as well etc etc

Basically a headache ! :evil:

So, what I am asking is: (finally)

Is there an easier way of communicating between the Service and the running ActiveX EXE when security is not to be modified ?

To save you some time, I have already looked in MultiUse and GlobalSingleUse with the same problems (again need to explicitly run in the same domain).

Using DDE is not an option. (assume I am planning to move to .NET)

Using Winsock is a potential but relys on opening ports on the client that might be in use, can get messy.

I thought of Named Pipes but have no serious knowledge or way of implementing in VB.

Windows messaging (via SendMessage) just doesn't cut it.

To give another spin on the whole dilema and something some of you may have faced already:
This is simular to having a Connection Pool Manager (connection being an object) siting on a server with various clients connecting to it using different authentications (different users). I notice that in such environments the same problem occurs where the Pool Manager gets created again and again for each unique user that tries to access it. A pool manager should be only 1 instance providing access to connections from his pool. (like MTS for example)

Finally, this is meant to be a Command-Response type of communication.

If you can help, much appreciated !


(I might be asking for too much)

Running MySql Connection As A Windows Service
I have been given an exercise to design a simple form in which the user enter 2 SQL queries. The queries are executed displaying the results and time it took to execute. This would be fairly simple apart from the fact that the DB connection and execution time need to be run as a windows service.

I have no idea where to start when it comes to windows services. Can anybody point me in the right direction

FindNextFile, UNC Paths And Running As A Service Returns '-1'
I've run into a very strange problem regarding the FindFirstFile and FindNextFile API call. I created an application that uses the function below to retrieve a list of files and store them. If I assign a UNC Path, this works fine as long as the application runs as a standard .exe. However, if I try starting the application using the NT Service control (Under Windows XP SP1) the FindNextFile API returns a '-1' consistently.

My thought is that this is an OS limitation that is intentionally prohibiting the code from running to avoid possible Trojan/Virus from spreading. However, I was wondering if anyone has run into this or knows of a workaround.

Here's the main portion of the code, much of it came from Microsoft's knowledge base...

The line below "hSearch = FindFirstFile(sDirSpec & sSpec, WFD)" returns a '-1' if the directory being searched is a UNC Path and the app. is running as a service. If scanning a local folder as a standard .exe, it returns the correct file handle.


VB Code:
Public Function LoadFiles( _                        ByVal path As String, _                        Optional ByVal bRecursive As Boolean = False, _                        Optional ByVal pb) _                As Long                Dim dircount As LongDim FileName As String   ' Walking filename variable...Dim DirName As String    ' SubDirectory NameDim dirNames() As String ' Buffer for directory name entriesDim nDir As Integer   ' Number of directories in this pathDim i As Integer      ' For-loop counter...Dim hSearch As Long   ' Search HandleDim WFD As WIN32_FIND_DATADim Cont As IntegerDim FT As FILETIMEDim ST As SYSTEMTIMEDim DateCStr As String, DateMStr As StringDim sFileSpec As StringDim sDirSpec As StringDim sSpec As StringDim fileCount As Long     sSpec = ts.sFilename(path, efpFileNameAndExt)    sDirSpec = ts.sAppend(ts.sFilename(path, efpFilePath), "")      ' Search subdirectories if necessary   If bRecursive = True Then        ' Search for subdirectories.        nDir = 0        ReDim dirNames(nDir)        Cont = True        hSearch = FindFirstFile(sDirSpec & "*", WFD)                If hSearch <> INVALID_HANDLE_VALUE Then           Do While Cont              DirName = StripNulls(WFD.cFileName)              ' Ignore the current and encompassing directories.              If (DirName <> ".") And (DirName <> "..") Then                 ' Check for directory with bitwise comparison.                 If GetFileAttributes(sDirSpec & DirName) And _                  FILE_ATTRIBUTE_DIRECTORY Then                    dirNames(nDir) = DirName                    dircount = dircount + 1                    nDir = nDir + 1                    ReDim Preserve dirNames(nDir)                  End If              End If              Cont = FindNextFile(hSearch, WFD)  ' Get next subdirectory.           Loop           Cont = FindClose(hSearch)        End If    End If        ' Walk through this directory and sum file sizes.   hSearch = FindFirstFile(sDirSpec & sSpec, WFD)   Cont = True        ' The value of 'hSearch' is '-1' when this code is run as a service and is scanning a UNC Path.    'MsgBox hSearch      If hSearch <> INVALID_HANDLE_VALUE Then    Cont = True      While Cont         FileName = StripNulls(WFD.cFileName)            If (FileName <> ".") And (FileName <> "..") And _              ((GetFileAttributes(sDirSpec & FileName) And _               FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY) Then                                          LoadFiles = LoadFiles + (WFD.nFileSizeHigh * _             MAXDWORD) + WFD.nFileSizeLow            fileCount = fileCount + 1                                   Set oFile = New clsFile            oFile.sFilename = ts.sFilename(sDirSpec, efpFilePath) & StripNulls(ts.sNT(WFD.cFileName))            mCol.Add oFile          End If         Cont = FindNextFile(hSearch, WFD)  ' Get next file      Wend      Cont = FindClose(hSearch)   End If     LoadFiles = mCol.Count End Function

Copyright © 2005-08 www.BigResource.com, All rights reserved