How some services start without restart where as some require restart - sql-server

Some of the windows services will start only after restarting the pc where as some start as soon as software is installed.
For example sql server(instance name) will start as soon as it is installed. Some other service requires restart.After restarting that computer it will start appearing in services.msc. Does it done by using registry? I got a link related to registry of services .But i am not able to track which one does it? Is it registry or something else?
(Setting service to manual or automatic is different,my question is about service added during the install of software for the first time)

You shouldn't be directly manipulating the registry to create a service. You should be using the service control manager API's to create and if desired start the service. The registry values are documented but they are still private to the API and only take effect upon reboot. Using the API will take affect immediately and the registry changes are done by the API.
If you are using Windows Installer you can let the installer handle all of this for you by using the Windows Installer's ServiceInstall and ServiceControl tables.
Some services have dependencies on resources that aren't available until after a reboot. One example might be a locked file that will be overwritten during startup via the Pending Files Rename Operations pattern. Another gotcha is if the service has a dependency on a system environment variable. After updating the registry to set the environment you are supposed to send a message to the broadcast address informing all processes on a settings change. Unfortunately the service control manager ignores these messages so it takes a reboot to catch up.
Other examples would be on a case by case basis.

Related

Can systemd restart a service when a specific binary on the server is updated?

On Ubuntu 18.04 I have Unattended Upgrades update apps regularly including a 3rd party PPA that installs a binary /usr/bin/some_app. My systemd unit file runs that service via ExecStart=/usr/bin/some_app. I can verify the updates work on schedule in /var/log/apt/history.log.
However even when the binary is updated via Unattended Upgrades systemd doesn't restart the app, I assume because some_app is started via a custom unit file unrelated to that PPA. So from the cli some_app --version shows v2.0.0 but systemd is still running v1.0.0.
Does systemd have a method to track a file or detect the binary referenced in ExecStart has changed on disk and it should restart? A backup hack for me would be using RuntimeMaxSec= which would get the job done, but I was hoping something more elegant existed
You could try adding a .path unit (man systemd.path) to watch for a close() after write() change to the file, which then restarts your app service. Not tested:
/etc/systemd/system/myappwatch.path
[Unit]
Description=watch for changed file
[Path]
PathChanged=/usr/bin/some_app
#Unit=myappwatch.service
/etc/systemd/system/myappwatch.service
[Service]
ExecStart=/bin/systemctl restart myapp.service
You might be able to replace the systemctl restart with something magic like Conflicts=myapp but I'll let you experiment. You also need to enable the .path unit as usual with an appropriate WantedBy=. I'm not sure what happens if the path is a symbolic link, so perhaps you should resolve the path to the real file is that is the case.

Remote Desktop Application - Start multiple sessions on my client PC

I have a windows 2016 server running RDS. It is configured to run a single application when a user accesses it from a .rdp shortcut. The user just sees the application as though it is running on their local machine, not a whole remote desktop.
If from a client PC, if I launch the application and log in then I can see a new connection in the RD Gateway manager.
However if I launch the application from the same client PC multiple times I am only asked to login the first time, and whilst I see many instances of the application I only see one connection in the RD gateway manager.
I would like a new connection each time I launch the application, so that I can simulate multiple users running the app concurrently in their own sessions.
I have tried adding "prompt for credentials on client:i:1" to the .rdp shortcut and this has no effect.
Thanks you your help.
I don't think it's possible. Let me try to explain:
Whenever you launch the RDP file, you connect to a session on the RDSH. Now, if you want separate connections, that means that there should be multiple sessions (probably for the same user since the credentials don't change) which is not allowed by the RDSH by default.
Assuming you get passed multiple sessions for same user, MSTSC actually recognizes that for the given RDP file, there is already an open connection, so it will try to reuse that.
Last but not least, there is the problem of licensing - you are "working around" the system: both per-device and per-user licensing would report 1, therefore it would probably be a violation of ToS.
It would be much more useful if you could tell us what you are trying to achieve and then maybe we can help you more.
P.S.: This question has nothing to do with programming, so it probably belongs to https://superuser.com
Hi I figured out a solution to this, so I will share in case it is useful for anyone else.
Modify the hosts file to include different names for the target machine ip address:
eg:
51.xxx.159.233 test1.xxx.uk-user1
51.xxx.159.233 test1.xxx.uk-user2
51.xxx.159.233 test1.xxx.uk-user3
51.xxx.159.233 test1.xxx.uk-user4
Then in each rdp launch shortcut, reference a different alias.
eg:
Shortcut1:
full address:s:test1.xxx.uk-user4
Shortcut2:
full address:s:test1.xxx.uk-user3
Then when the RDP is launched it will ask you to log in even if you already have an active connection and server will have a new user logged into it.
Hope this helps somone in the future.

Credentails Manager service is stopped

Hi,
I am getting the below error when trying to update my view . Also, creds manager service is stopped and not getting started.
As long as the credmanager.exe is not started, none of the view (snapshot or dynamic) will work. So you need to debug that first.
Typically, you would check the ClearCase logs, and the Windows event, to see what the issue is. See "how to fix or investigate 'Operation “view_ws_is_ws_view” failed'?", using cleartool getlog.
That kind of error ("This application has failed to start becauselibatriaks.dllwas not found. Re-installing the application may fix this problem") was seen with rather old versions of ClearCase (7.0.1).
See for instance this thread.
If the DLL is present and the directory is in your path you should never
get this error.
Check to see how far ...\rational\clearcase\bin is down your SYSTEM path, and make sure the DLL's are in there.
ccgzip.exe will be called (by the client process) when checking in any files that fall back to the "compressed_file" element type. It may be called by the view server during file opens and checkouts to construct cleartext if needed. The former uses your user path, the latter will normally use the SYSTEM path.
We've seen odd behavior on Windows when the path gets >500 characters
long, though there seems to be no "official" limit to the length this environment variable (%PATH%) can grow to.
The error message you see is likely a path issue. Whether that's related to the other issue is unknown...
Is the albd server process running? The credential manager service is flagged to depend on this service. If that service fails to start, or terminates, the credential manager service will also fail.
A service startup failure should be in the Application or System Event logs. and from there the "Troubleshooting albd startup failures" technote on ibm.com would likely be a good place to start.

Using OpenSCManager to load the Service Database of a non-running Windows installation

I am pulling (in the IT sense) hard drives from working machines and need to adjust their service configuration in the registry. In the Windows API OpenSCManager, which is used to edit services in the registry, has a sparsely documented lpDatabaseName parameter. Can I use that, say if a Working but not running Windows install is mounted as drive E:\? (the running Windows install is mounted on drive C:\)
Could I do e.g. OpenSCManager(NULL, "E:\Windows\WHAT_IS_THE_FILENAME", SC_MANAGER_ALL_ACCESS). Then use the handle to edit the service configuration on drive E:\?
What is the file path for the second parameter? i.e. where would I find this service database file on drive E:\?
According to the SCM remote protocol specification, lpDatabaseName can only be NULL, "ServicesActive", or "ServicesFailed".

"Out of browser" web application running at Start-Up?

I've become familiar with the new concept of "out of browser" web applications, supported in the recent Silverlight, JavaFX, Adobe AIR etc.
Listening recently to a podcast on the subject by Scott Hanselman, I've become aware that one of the purposes behind these new architectures is to allow for "desktop-application-feel". Also, I understand some (or all) of these allow for some offline access to a sandbox of resources. This really sounds as if these frameworks could be an alternative to "real" desktop applications, as long as the application does not require messing with the user's machine (i.e. access to peripherals, certain file IO, etc).
I have a very specific question. My application needs to run at start-up. Is it possible to do so using such a framework without requiring the user to download and run a certain executable?
For example, I could always direct the user to download a small EXE that will put a .lnk file in the start-up directory, but I want to avoid such a patch.
To summarize: is it possible to have an out-of-browser web application setup itself to run at start-up without requiring file download?
To further clarify, this question does not come from an "evil" place, but rather from trying to decide whether "out-of-browser" frameworks are indeed a proper alternative to a desktop application, for my specific requirements.
The BkMark example here shows how to start an application on startup using Adobe Air. So, yes it is possible.
So, here's the deal: web apps in general will have a security context around them, and by default won't have access to write to the filesystem (outside of a temp files), access the registry, etc.
One way is, as you said, have the user run something or configure it so the lnk is executed on startup.
Another way, and I think, more in line of what you want, is that the user can run the program himself, click some button in the application, and it's configured.
I know with Java you could do this, but the user has to allow full access to their system, because your app would need to change System configuration. Then you could just configure it (by writing a lnk to your WebStart JNLP in the Startup folder)
For Internet Exploder, Javascript apps do have write access to the disk.
For other (better-secured) browsers you will either need to have a download, or Adobe AIR.
Assuming you are building for Windows, launching an executable at startup can be done several ways.
For user session startup, you can achieve this either by putting a lnk file in the appropriate folder, or with a registry entry. For operating system startup, you can achieve this with a registry entry. There are several permutations:
run application once on boot (UI not allowed)
run application every boot (UI not allowed)
start service every boot according to policy set in registry
run application once on user session start
run application every user session
Since an out of browser application has UI I expect you mean run application every user session and in this case you may as well put an LNK file in the user's startup folder.
I just created a shortcut for an SL4 OOB application, and this was the Target of the shortcut:
"C:\Program Files (x86)\Microsoft Silverlight\sllauncher.exe" 2635882436.localhost
A search of my disk revealed that location 2635882436.localhost is a folder.
C:\Users\<mylogin>\AppData\LocalLow\Microsoft\Silverlight\OutOfBrowser\2635882436.localhost
I rather doubt an OOB app of any type could place a shortcut in the Startup folder unless you somehow obtained Full Trust.

Resources