I'd like to configure Windows programmatically to use a user-specified SNTP server. Is there a function in the Windows API for that?
You can do it through the registry:
Registry entries for the W32Time service
Configuring the Time Service: NtpServer and SpecialPollInterval
Alternatively, you could interact with the W32tm console utility.
The Date and Time control panel (timedate.cpl) does this with a call to W32TimeSetConfig from w32time.dll, but that appears to do nothing but set the NtpServer value in HKLM\System\CurrentControlSet\Services\W32Time\Parameters.
Related
I am trying to add mongoDB service on windows startup but still I am not able to do it.
Every time i have to start mongoDB service manually.
I have looked into how to add application on startup in windows but it only starts application not service like this
So can you help me to find solution to add mongoDB service to startup in windows so it can automatically starts? Thanks in advance.
In windows Control Panel\All Control Panel Items\Administrative Tools\Services you can find the MongoDB Database Server service and change it's Startup Type to Automatic.
If no MongoDB Database Server service is listed in the services, you need to install it as MongoDB as a Windows service as described here.
You can check if the MongoDB Server is enabled on the windows services list. You can verify by opening the Run application Windows Key + R and execute the command msconfig. This will open a window, where you can navigate to services and verify if the MongoDB Server box is enabled.
.
Is there anyway to call a windows service that's already running or a process to get info? What my goal is to find out if my windows service is an infinite loop or dead lock and see if it responds. So I want to be able to pass an argument from another program to a windows service and want it to to return a string or number. Is this possible? I can change the windows service to accommodate this. I am thinking of an event or something.
Note: I am not supposed to have the service write to a file or database.
You can host a WCF service in your Windows Service which you could call to get status information.
Here are a couple of links on doing that:
Can I host a WCF Service in a windows service?
How to: Host a WCF Service in a Managed Windows Service
The MyProgram.exe is made to listen the request from pipe and using command prompt its working perfect but I tried to work it by using windows service but not success I have tried following steps on windows server 2008 enterprise:
> sc create MyService binPath= "C:\test\MyProgram.exe" DisplayName= "MyProgramService"
>[SC] CreateService SUCCESS
>sc start MyService
[SC] StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
reference
So I read on one blog that we need to create registry entry for the same then I tried the following steps
I found my newly created service under: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\MyService
Click the key named MyService (it looks like a folder) from the menu in regedit. Select “edit” and “new” and then select “key.” This will create a new key which you should name “Parameters.” Next, right- click on the key that you just named “Parameters” and select “new” and then “string value.” Name the value “Application.” Double-click the string value and a box will pop up. In the box under “value data”, you need to put the full path to the Dropbox. In my case, the path was: C:\test\MyProgram.exe\MyProgram.exe
Start your new service. Navigate to the services list in the control panel‘s administrative tools or simply type services.msc in the run box. Find DropBox in the list and start it. New services should be set to start automatically, but feel free to check it to be sure.
But the service start for a few seconds and get terminated. When I start manually service from services.msc it give error
StartService FAILED 1053:
The service did not respond to the start or control request in a timely fashion.
Not sure why any one have work on it, please guidance to make it as service.
You can't run just any EXE as a Windows service. You must have an exe which understands what it means to be a service and which communicates appropriately with the Windows Service Control Manager.
Refer to the Microsoft documentation, starting with http://msdn.microsoft.com/en-us/library/windows/desktop/ms686953(v=vs.85).aspx.
Here's what I want to do:
a program that listens in the network for a message, and when that message is received, if the user is not logged in (for example the computer just powered on and windows displays the classic login screen), it automatically logs in a certain user accordingly to the message. the username and password are known and stored safely inside the computer in a configuration for the program i'm talking about.
What I had in mind was a windows service that starts with the computer and also listens to those messages, and if one is received, then it does it's job
but I have no idea of where to start
(basically i'm trying to login a user without having to type the password, which I said is stored and known - need something mostly like the fingerprint software windows 7 comes with, and the ones that you had to install in vista/xp so that fingerprint login would work (fingerprint was only an example) )
There's two methods to pursue depending upon which operating system you're looking to run under.
For Windows XP, Windows 2000, and Windows Server 2003 you need to create a GINA.DLL. This is a replacement DLL which must follow specific rules which handles the authentication process. In your case your replacement DLL would be known by the service which was listening for your start signal, and it would make a call into the DLL with the username and password as appropriate.
MSDN Magazine article on customizing GINA.DLL
MSDN entry on GINA
For Windows Vista/7 and above you'll need to look into the Credential Provider API.
MSDN Magazine article on Credential Provider API in Vista.
MSDN entry on Credential Provider API
You can use windows auto logon feature to do this.
Create a service which waits for the required data on a network socket. Make sure this service is started after the network service (Tcpip). Modify winlogon service properties (manually) so that it depends on your service. By depends, I mean that winlogon service is started after your service.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon to 1
Once you receive the data on your network socket, set the following registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword
Once the registry settings are in place, then the winlogon service can read those values and proceed with the login process.
For more details on setting the registry values refer: http://support.microsoft.com/kb/315231
I want clarify a little the suggestion of Vikram.exe.
Of cause the usage of AutoAdminLogon seems native for the problem, but saving of the password in registry as a clear text under HKLM\...\Winlogon\DefaultPassword is not good. Since Windows 2000 it is supported the usage of the secrets DefaultPassword which makes the same effect as the DefaultPassword registry value (see Protecting the Automatic Logon Password for the code example).
Another way to force user login or to do any other actions on the login screen is switching to the Winlogon desktop (full name WinSta0\Winlogon). You can use SwitchDesktop and SetProcessWindowStation to do this (see Window Stations and Desktops). If the service run under System account you will have all rights to do this. Depend on the configuration of your service it could be also needed to use SetTokenInformation with TokenSessionId to change the current session id. After the service process will run on the WinSta0\Winlogon desktop you can use functions like FindWindow and other GUI API to place any information in controls of the window (user name, password and so on) of other process. So you can implement more complex scenarios.
Firstly let me just say im not 100% sure how to fully complete such a application but I have a few tips.
you will need to create a Windows Service that starts during the Pre-Login, you can create a service in C#, An example of creating a C# Service is linked below:
http://msdn.microsoft.com/en-us/library/zt39148a(VS.80).aspx
Within your application you would set the property Startup Type to Automatic, This will automatically start your service on boot.
You should know that windows services run under a secure context by account so you will have to get your service to run with privs do do this.
In your Service Properties you can Click Log On and you can
To specify that the service uses the Local Service account, click This account, and then type the following NT AUTHORITY\LocalService.
To specify that the service uses the Network Service account, click This account, and then type the following NT AUTHORITY\NetworkService.
As your trying to do this remotly you will have to look at WMI (Windows Management Instrumentation) and you will be able to start/stop and send commands to your service.
Your service then would send a command to the Login Management (Not Sure of the name).
you may also wish to check this WOL class which will switch the computer on remotely as long as it supports Wake On LAN, If this is for a corporate environment then I advise you to check your network cards to make sure they are supported
http://www.codeproject.com/KB/IP/wolclass.aspx
I know of some education software that I use for schools that's called CC4 ( http://www.rm.com/shops/rmshop/story.aspx?cref=PS1026195 ) and we can do exactly what you need within this system, I'm not fully sure of how it works fully but i believe it takes the same principles described above.
I have a requirement in the project such that we have to stop a specific service say "x" in a remote machine (which is on the same LAN), change the registry key remotely and start the service again.
I tried the command sc \server stop service, but I got the error:
[SC] GetServiceKeyName FAILED 1060:
The specified service does not exist as an installed service.
I am using Windows 2003 SP1. Are there any built in commands or APIs that are available on Windows?
I need the commmand to run on the command prompt.
Also keep in mind that the "service name" argument expected by the "sc" command line tool doesn't always equate to the name you see within the services control panel applet (which is the service "display name").
For example, the service that as appears "Adobe Acrobat Update Service" in my services control panel applet has an actual name of "AdobeARMservice". You must use the latter, but not the former, when managing the service through the "sc" utility.
Example:
sc Stop "AdobeARMservice" (works)
sc Stop "Adobe Acrobat Update Service" (doesn't work)
To get the "real" name of a service, double-click its entry in the service control panel applet and see the "service name" field on the General tab.
Of course in some cases, the display name and the service name are the same.
You may want to look into PSTools from SysInternals. Those tools are freely available and can help you manage processes on a remote Windows machine.
The tools included in the PsTools suite, which are downloadable as a package, are:
PsExec - execute processes remotely
PsFile - shows files opened remotely
PsGetSid - display the SID of a computer or a user
PsInfo - list information about a system
PsKill - kill processes by name or process ID
PsList - list detailed information about processes
PsLoggedOn - see who's logged on locally and via resource sharing
PsLogList - dump event log records
PsPasswd - changes account passwords
PsService - view and control services
PsShutdown - shuts down and optionally reboots a computer
PsSuspend - suspends processes
PsUptime - shows you how long a system has been running since its last reboot
From this URL:
To stop a service remotely you can use the command sc.
Example:
> sc \\computer stop "Service Name"
> sc \\computer start "Service Name"
Perhaps you are missing a "\" character?
Use OpenCSManager, then OpenService, then StartService.