Trying to make a windows store app that runs when the laptop lid is closed - windows-8.1

Is there any way to make an app such that, say the user presses a button (in the app) and directly closes the lid, then the computer doesn't go to sleep (that way my app is still running) and I sort of make my own temporary log in screen as soon as the user opens the lid? (and that login screen essentially freezes all windows 8 functionality until the user logs in)
Im trying to make an alarm app that can only be shut off by logging in.
Also the app in question is a windows store app (written in C#) for windows 8.

Yes, with administrative privileges. Lid signal handling is part of the OS power settings and is controllable from an app if it is run as administrator or obtains admin privileges at runtime with UAC.
Powercfg can do this if you run a sub-process with cmd /c:
powercfg -setacvalueindex 5ca83367-6e45-459f-a27b-476b1d01c936 0
powercfg -setdcvalueindex 5ca83367-6e45-459f-a27b-476b1d01c936 0
There may be a .NET API for power management as well.

Related

AutoLogoff 5/10 minutes after AutoLogon on Windows Server 2019

I am currently trying to use the Windows Server 2019 Task Manager tool to plan an activity.
The activity should be the execution of C:\Windows\System32\logoff.exe 5 or 10 minutes after the user (Administrator) Autologon.
Automatic Logoff should only occur when Autologon for Administrator executes. For example, everytime the server is restarted after an update, but not when a user enters as Administrator or other specifying his/her password.
I have set the Autologon using a Microsoft app which can be found at this link: https://learn.microsoft.com/en-us/sysinternals/downloads/autologon
I am now struggling trying to identify the correct event ID and the right settings to make all of it work in Task Manager.
For now, I have set this one: C:\Windows\System32\logoff.exe as the event that should be executed upon the occurrence of the AutoLogon, but as for the latter, I have no idea on how to set it.
Could you please help me out finding a solution?

NSIS, Do not show uac dialog

After installation of the program, can not make uac dialog box disappear when the program is run?
Can I grant administrator privileges to install and have it run automatically at install time?
You cannot bypass UAC, the user is supposed to be in control of their computer, that is the whole point of UAC! If you want to do machine wide changes that require administrator privileges there is no way around it, the user has to elevate with UAC at least once.
If you want the installed application to run elevated automatically then you must write a custom service that can be started on demand. When a administrator starts your application un-elevated the application must start your service and ask it to launch a elevated instance. The service must then call CreateProcessAsUser with the linked elevated token. This is too difficult for most developers and most applications just have to accept the fact that they must display a UAC prompt when they are started.

The service cannot accept control messages at this time

I just stopped an Application Pool in IIS. When trying to start it, IIS complains that,
The service cannot accept control messages at this time. (Exception from HRESULT: 0x80080425).
What gives? Whence did this error come?
Looking at the Event Viewer > System shows these warnings:
A worker process '1456' serving application pool 'MyAppPool' failed to stop a listener channel for protocol 'http' in the allotted time. The data field contains the error number.
A process serving application pool 'MyAppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '10592'. The data field contains the error number.
A process serving application pool 'MyAppPool' exceeded time limits during shut down. The process id was '10516'.
This resolved itself after about 5-minutes, at which point we tried to restart the website, and received:
The World Wide Web Publish Service (W3SVC) is stopped. Web sites cannot be started unless the World Wide Web Publishing Service (W3SVC) is running.
So, we started the W3SVC service, and then we could start our website.
This helped me: just wait about a minute or two.
Wait a few minutes, then retry your operation.
Ref: https://msdn.microsoft.com/en-us/library/ms833805.aspx
The error message could result due to the following reason:
The service associated with Credential Manager does not start.
Some files associated with the application have gone corrupt.
Please follow the steps mentioned below to resolve the issue:
Method 1:
Click on the “Start”
In the text box that reads “Search Program and Files” type “Services”
Right click on “Services” and select “Run as Administrator”
In the Services Window, look for Credential Manager Service and “Stop” it.
Restart the computer and “Start” the Credential Manager Service and set it to “Automatic”.
Restart the computer and it should work fine.
Method 2:
1. Run System File Checker. Refer to the link mentioned below for additional information:
http://support.microsoft.com/kb/929833
In my case, the VS debugger was attached to the w3wp process. After detaching the debugger, I was able to restart the Application Pool
I stopped the IIS Worker Process (in task manager), and then started the IIS again.
It worked.
I killed related w3wp.exe (on a friends' advise) at task manager and it worked.
Note: Use at your own risk. Be careful picking which one to kill.
Restarting the machine worked for me but not every time.
If you are really stuck on this then follow below steps
Open Task Manager
A window will open. Click on Details tab.
Search for the process name you wanted to restart/stop.
Select process, right click on it, select End task option.
A confirmation dialog box will appear. Click on End process button.
Now try to restart your service from Services.msc window.
I forgot I had mine attached to Visual Studio debugger. Be sure to disconnect from there, and then wait a moment. Otherwise killing the process viewing the PID from the Worker Processes functionality of IIS manager will work too.
Restarting the IIS windows service (World Wide Web Publishing Service) and then starting the application pool has worked for me. However, as the top answer suggests it may have just been the waiting that caused it to subsequently work.
I had this issue recently,
Problem statement:
Mine was a windows service that I run locally by attaching VS debugger. When I stop debugging and try to restart/stop the service (under services.msc) I used to get the mentioned error.
Solution:
Open up Task manager.
Search for the service (based on the exe name and not service name, for those that are different).
Kill the service.
On doing the above the service is stopped.
Being impatient, I created a new App Pool with the same settings and used that.
I kept having this problem whenever I tried to start an app pool more than once. Rather than rebooting, I simply run the Application Information Service. (Note: This service is set to run manually on my system, which may be the reason for the problem.) From its description, it seems obvious that it is somehow involved:
Facilitates the running of interactive applications with additional administrative privileges. If this service is stopped, users will be unable to launch applications with the additional administrative privileges they may require to perform desired user tasks.
Presumably, IIS manager (as well as most other processes running as an administrator) does not maintain admin privileges throughout the life of the process, but instead request admin rights from the Application Information service on a case-by-case basis.
Source: social.technech.microsoft.com

Application run as service is not appearing

I have two PCs and I'm logged in both with same user id(have the administration rights). I have installed the service on both PCs. I'm getting a strange issue:
1. If I remove both PCs from network then starting the service makes application appear on both the PCs.
2. If both PCs are in network then One PC shows application while on other it does not appear. however, if I check the task manager, application is running fine.
I find out following things:
1. On PC where application appears, active desktop is "Default"
2. On PC where application does not appear, active desktop is "Screen-Saver". I checked that non of the screen-saver are active and running on this pc.
3. Now If I remove the PCs from network and re-connect then behaviour just got switched. I.e. where it was not working start appearing application but not on other PC.
Why one PC is in screen-saver mode while other in Default? Is this has to do with common login id? How can I work around this issue?
These two services are independent of each other. These service createprocess() which invokes a VB application.
Another question I have is that if I'm not in N/w and run the service then it VB GUI appears properly. If I use remote desktop to start the service, the service appears properly but the VB GUI does not appear :-(
The active desktop at this moment is 'winlogon'. I'm not able to make the VB GUI visible if I give lpdesktop = "WinSta0\Desktop" or "WinSta0\winlogon" or "WinSta0\screen-saver". Please note that I'm accessing the system where service is physically running through remote desktop.
Can someone let me know what I needs to do to make VB GUI appear remotely if I start the service remotely?

Application Pool shutting down

Whenever I try to launch a site in the 4.0 App Pool shuts down immediately (if it ever started) an leaves an event in the event log:
Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off.
The user specified is IIS APPPOOL\DefaultAppPool
followed by another event log entry
Windows cannot log you on because your profile cannot be loaded. Check that you are connected to the network, and that your network is functioning correctly.
This machine is running Win 7 Ultimate
If the error is actually what is indicated in the event log, how can I reset the app pool users?
I just ran into this after upgrading my Win7 Ultimate x64 machine to SP1. The aforementioned message was found in the Application event log. It was accompanied by its good friend, "Application pool 'DefaultAppPool' is being automatically disabled due to a series of failures in the process(es) serving that application pool." in the System event log.
I changed the advanced setting of the app pool, "Load User Profile" from True to False and my app pool is running again using the configured identity (which, in my case is a domain account).
I had this problem on Windows 10, following an upgrade from Windows 8. The problem was I had a corrupt Default profile. (This can apparently occur when upgrading to Windows 10.)
When logging in for the first time with a new user, the Default profile is copied to create the profile for the new user. If it's corrupt, this can cause the login to fail for the new user.
This worked for me on Windows 10:
Take a zip of C:\Users\Default from a Windows 10 installation that doesn't have this problem
Rename C:\Users\Default on the Windows 10 install that is having problems, to Default.Old
Unzip the non-corrupt Default profile into C:\Users
Now try again with Load User Profile set to True. It should work.
In my case, Windows 10 version 1909, IIS 10, app pool running under domain account, app pool's "Load User Profile" or "Rapid-Fail Protection" settings had no effect on the issue.
When I deleted both application and it's app pool from IIS, recreated them, issue got resolved. New app pool does have Load User Profile set to true just like it was before.

Resources