windows-services

Check if no user is currently logged on to Windows

可紊 提交于 2019-12-04 07:51:49
问题 I'm writing a Windows Service application which listens for connections and performs certain tasks as instructed from a different application running on another computer on the network. One of the tasks ensures no user is currently logged on, locks the workstation, delete some files, and then restarts the system. I considered using this solution to look through the list of running processes and check the user names, determining if no user is logged on by matchhing the user names against

How does a Windows service differ from a standard exe?

房东的猫 提交于 2019-12-04 07:47:19
问题 What's the difference between a Windows service and a standard exe? 回答1: A windows service always runs once the computer starts up (as long as it's so configured). A standard EXE only runs when a user is logged in, and will stop if the user logs out. You would use a windows service for things that always need to run even if nobody is logged in. You would use a standard EXE for programs that a user will run while logged in. 回答2: A Windows service has a special ServiceMain function and must

How to uninstall a windows service and delete its files without rebooting

↘锁芯ラ 提交于 2019-12-04 07:40:56
问题 My current project involves deploying an upgraded .exe file that runs as a Windows Service. In order to overwrite the existing .exe with the new version, I currently need to: Stop the service Uninstall the service Reboot the system (so Windows releases it's hold on the file) Deploy the new .exe Reinstall the service Start the upgraded service. I'd like to avoid the reboot, so that this can be a fully scripted/automated upgrade. Is there any way to avoid rebooting? Maybe a command-line tool

How to get all Windows service names starting with a common word?

五迷三道 提交于 2019-12-04 07:33:02
问题 There are some windows services hosted whose display name starts with a common name (here NATION). For example: NATION-CITY NATION-STATE NATION-Village Is there some command to get all the services like 'NATION-'. Finally I need to stop, start and restart such services using the command promt. 回答1: sc queryex type= service state= all | find /i "NATION" use /i for case insensitive search the white space after type= is deliberate and required 回答2: Using PowerShell, you can use the following Get

How do I get the ports opened by a Windows Service?

早过忘川 提交于 2019-12-04 07:20:28
This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 7 years ago . Learn more . I want to get the list of window services and their ports in C#. I'm able to get all window services by using ServiceController but I'm unable to get ports of these services. Neolisk Please check this question on stackoverlow . It is not exactly the same as you are asking, but it points to a useful function called GetExtendedTcpTable available through PInvoke , that can do what you need. Also check this one . Anonymous Coward After a lot of

Forcing windows to wait for a service to stop when it is shutting down

末鹿安然 提交于 2019-12-04 06:50:38
I'm having an issue that I can't figure out regarding a Windows Service I have written in C#. What I am trying to do is wait for a specified period for a child process to terminate before I am forced to kill it and stop the service. I have set my timeout for anywhere from 5 to 15 seconds and my service waits the appropriate amount of time and then kills the child and stops when I stop it via the mmc service window. However if I shutdown the computer my service gets blown away before it is able to wait and stop properly. I have read that Windows allows for a timeout of 30 seconds for a service

How to communicate between Windows Services

萝らか妹 提交于 2019-12-04 06:41:06
I have 2 windows services that I created using C#. I would like one of the services to call a function in the second windows service. How should I do it? EDIT: The issue is That I have to application that running ( I don't need them to be Rather service Process is good too) but I need this 2 application to communicate, this 2 application are on the same server, jglouie Sure. There are a bunch of IPC mechanisms you could use. Remoting, TCP/HTTP Listeners, etc. Does either service provide functionality that might be useful outside of the other service? See this thread for more ideas: IPC

How do I get the Service Display name in C++?

白昼怎懂夜的黑 提交于 2019-12-04 06:10:11
问题 I am trying to get the display name of the running service using c++. I was trying to use the GetServiceDisplayName function but it does not seem to be working, not sure why. TTServiceBegin( const char *svcName, PFNSERVICE pfnService, bool *svc, PFNTERMINATE pfnTerm, int flags, int argc, char *argv[], DWORD dynamiteThreadWaitTime ) { SC_HANDLE serviceStatusHandle; DWORD dwSizeNeeded = 0 ; TCHAR* szKeyName = NULL ; serviceStatusHandle=OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE ,SC_MANAGER

Access Denied when executing Process.Start from Windows Service

随声附和 提交于 2019-12-04 06:05:39
I'm trying to run a process from the service as another user. Process.Start(applicationPath, params, account, SecureStringPassword, ""); A service is running under the "Local System" account. The account parameter is a string like "WORKSTATION6\Tester". This user is a member of the Administrators group. "Application Path" refers to Program Files, so every user can read from it. But I have an "Access Denied" Exception every time I try to start the process. What can you advice? There is an example of how to use Process.Start on the SecureString page. http://msdn.microsoft.com/en-us/library

SQL “login failed for user [username]” error for windows service, but SSMS login works

社会主义新天地 提交于 2019-12-04 05:31:15
I'm writing a windows service that needs to connect to a SQL server to retrieve some information. However, the server doesn't allow me to connect: login failed for user [domain/username] . The strange part is that everything works totally fine from inside SSMS. I can log in, query the database, and everything works out perfectly. It's only through the windows service that it's throwing that error. For reference, here's the connection string I'm using: Data Source=sqlserveraddresshere;Initial Catalog=databasenamehere;User ID=domain\username;Password=password` I doubt that this is related, but