How can I automatically change the display settings for dual monitors to "mirror" when a user logs out? - windows

I have an situation where users are using a projector as a second monitor (extended desktop where the projector is primary monitor) in classrooms. The issue arises when the user logs out, they do not switch the computer to primary monitor, or change the screen display settings back to mirror. The result is faculty not seeing a log in screen when attempting to log into our computers since the primary monitor is the projector.
I have thought of using a batch file using DisplaySwitch.exe /clone, this will change the display settings to mirror. Seeing as this script needs to be run on log out, I used Windows Group Policy to run on user log out. This isn't working for me, and after some investigation I believe it is because the batch file is unable to finish as Windows is terminating the script before completion. I could be wrong on the reasoning for it not working. I have also replicated the script in VBscript and PowerShell and wasn't able to get either to run on log out.
So, is there a way to automatically change the display settings on a Windows system to "mirror" or "duplicate" when a user logs out?
#echo off
title Script to mirror screen
echo Switching to mirror screen
DisplaySwitch.exe /clone

Related

RunAs/Remote Desktop Windows Security - A Device attached to this device is not functioning correctly

Good Afternoon, never seen this one before in my years of working with Windows but im at a loss to try and find the solution to this one.
When users log on to their desktops as Non-Admin accounts, there are particular applications they need to run as different users due to the way some of the systems work. A load of system policies where updated for security at group policy level however now something strange is happening when the user initiates a RunAs by holding the shift key down or if they attempt to remote desktop to another machine, the NLA Windows Security box that prompts for credentials takes 5/10 minutes to appear.
When the user hovers over the taskbar icon, then over the window without clicking the Windows Security box displays as full screen missing the username and password box but when you click on it nothing happens and just disappears. Eventually after a few minutes the windows security box will appear and can log in as normal however the users jump into systems adhoc and cant be waiting for minutes at a time to put their credentials in which could cost a lot of user down time during the day.
I have tried looking at the security log but as you can imagine its filled with all sorts and trying to locate one specifically without knowing the issue is difficult at best. Has anyone had this issue before that can point me in any direction. I have to assume this is permission related on the devices trying to access something locally because when i log on to the devices with an account in the administrators group all these issues disappear and the windows security works as normal. Also, if they click "Run as administrator" they get the UAC credential box so i don't believe this is UAC related as its working by design just anything with "Windows Security" prompts. I should point out that whilst this is waiting - the File Explorer icon highlights under "Run As" like the explorer is waiting to do something.
OS - Windows 10 Pro
Acc - Domain Joined
Group policy enabled
Local Policy Disabled
Update: 21H2
Never seen this before but hoping one of you legends has!
Dev
Full Screen Box - Screenshot
For anyone reading this - although bizzare as it is...
It turns out it was McAfee Disk Encryption - there was a bug in the local FDE security provider causing it to hang every time it was accessed.
Update your McAfee FDE Client/Agent to the latest version

Audio Service Not Starting/Functioning Properly

My Audio Service refuses to function properly. I have tried so many different solutions I can't even recall all of them.
Here's how it started; I got home from work one day to see my computer has no video signal but is turned on and receiving input from my mouse/keyboard. I force restart my computer and, after it boots up, I see that the Windows Audio Service is stopped.
I first try to use the task manager to start the service (Audiosrv) and it would blink at Starting then immediately go back to Stopped. From here I went to the Services window and tried starting it from there (Windows Audio) and, after trying to start, says Access Denied (Error 0x80070005).
So after searching a solution I went into regedit and was told to add System as a permission group for AudioSrv and the AudioEndpointBreaker service. Turns out they were already there with FULL CONTROL for both.
I try to change the logon to use Local System Account (WITH INTERACT DESKTOP CHECKED!) and voila, my audio service is running! But my bad luck continues.
None of my speakers/headphones are creating sound even though the service turned on and I can see all my devices. As an attempt I tried to do test sound, and this error appears.
Keep in mind I've restarted after every one of these fixes, both the service and my computer afterwards. As a final attempt I tried to open the Command Prompt as administrator and entered sfc /scannow . After verifying, this message appears.
I honestly have no clue what could've happened while I was working, but I'd rather not have to reinstall my windows to lose all my files.
Recap of my attempts to solve
Start the Audiosrv service from Task Manager (failed to start but keep in mind the EndpointBreaker service was running)
Opened services window and tried starting the Windows Audio service (Access Denied [Error 0x80070005])
Tried adding System as permission group for AudioSrv and AudioEndpointBreaker to find out both already had Administrators, my user, and System with full Control.
Changed login to local system account with interact desktop control checked and it fixed! Supposedly. THIS WAS THE FIX FOR 99% OF PEOPLE ON THE FORUMS
After realizing my sound wasn't playing but my devices/control was showing up, tried testing sound and received an error.
Last resort I did a sfc /scannow command and was given the response shown above.
What should and what can I do to get my audio running?
SIDENOTE
When I drag the volume slider [which usually creates a tone with the volume adjusted], the speakers/headphones meter on the Sound window do NOT light up green (in other words they aren't showing sound receiving on its end)
I resolved this issue after doing a system restore.
Add the Local Service in the Local Users and Groups
Right-click This PC or My Computer, depending on which version of Windows you have, and select Manage from the dropdown menu.
To the right, you will see a System Tools section. Double click Local Users and Groups, and select Groups beneath it.
Right-click Administrators in the list in the middle of the window, and select Add to group.. from the dropdown menu.
Click Add, then Advanced, and then click Find Now. Double click Local Service, and click OK. You should see NT Authority\Local Service in the list, click OK. Close the Computer Management window and reboot your device. Your problem should be solved.
Then in services.msc change logon to LOCAL SYSTEM.
If you dont permission to run Windows Audio:
key windows + Services
search Windows Audio
right click settings
login
Local system account and allow the service to interact with the desktop
save and run Windows Audio

Keep windows GUI while switching windows user or closing remote connection

I need to run a GUI script (AutoHotKey, which makes mouse clicks and press keys) on:
A different windows user (i.e. I run the script, then switch user
while keeping the session active)
A remote Amazon windows server (using remote desktop) where I also
run the script then close the Remote Desktop while keeping the
instance running
Unfortunately, in both cases, the script doesn't run as it seems that Windows enters a "GUI-less" mode where all GUI components are not active anymore.
Is there any solution to this?
Any hint would be greatly appreciated as I've now lost days trying to solve this!
Many thanks, Thomas
I do not believe this is possible due to the way Remote Desktop is implemented. When you close the RD connection, the GUI is no longer drawn. Therefore, AutoHotkey is unable to perform mouse clicks and key presses.
A possible workaround would be to make some registry tweaks (if possible on your server) which allow GUI interaction while minimized.
Locate HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
Create RemoteDesktop SuppressWhenMinimized as DWORD with a value of 2
Registry Tweak Source

Getting blank (black) screenshot with automated screen capture using task scheduler

I am trying to troubleshoot a software bug in which we think an app may not be launching every time it is called. To test this, I created a series of scheduled tasks to launch the app, take a screenshot, and then close the app. These tasks are all run through .bat files.
Everything works fine except for the screenshots. When run as a scheduled task, the .jpg from the screen capture always shows a black box. If I execute the .bat file normally, the screenshot looks fine.
I am using nircmd to send the screen capture command and save it to a folder. The command I am using is as follows:
nircmd.exe savescreenshot "C:\File Path\"~$currdate.MMddyyyy$-~$currtime.HHmmss$.jpg
I am using Windows 7.
The task created is probably running in its own logon session, even if it is running as the same user.
Make your scheduled task run as the currently logged on user.
Keith Brown wrote an old but still valid detailled explaination of the logon session SID. The relevant part is at the middle, under "http://www.microsoft.com/msj/0599/security/security0599.aspx"
You can also poke around the access rigths with EnumWinStaGui.

Terminal session when minimized\disconnected returns a blank screen upon capturing desktop snapshot

I am using the below JAVA code to capture the desktop of a remote machine
Robot robot = new Robot();
BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ByteArrayOutputStream imageBytes = new ByteArrayOutputStream();
ImageIO.write(screenShot, "PNG", imageBytes);
return imageBytes.toByteArray();
However the captured image is blank, when the terminal session to the remote machine is either minimized or disconnected. I appreciate your help in resolving the issue, at the very least the minimized scenario.
Configuration:
I have the same issues with a physical machine running windows 7 and a virtual machine running windows server 2008 R2.
More insights from MSDN:
Why you get black screen when you disconnect from RDP ?
 
http://msdn.microsoft.com/en-us/library/aa383015%28VS.85%29.aspx
Here is my attempt to make things work, but none of the following did the trick:
 
How to get data when RDP window minimized ?
 
You can force the RDP display driver to send data when minized, try these steps and let me know how it goes:
 
1) Add the following key
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client\ Created a new DWORD value and named it RemoteDesktop_SuppressWhenMinimized. Specified 2 as the value data.
Note: Also tried adding the registry key to HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client\
 
2) Disable bitmap caching (http://technet.microsoft.com/en-us/library/cc737325(WS.10).aspx)
In the Remote Desktop Connection window, click Options.
On the Experience tab, verify that the Bitmap caching check box is selected. Or, to disable bitmap caching, clear theBitmap caching check box
If you minimize the Remote Desktop window, Windows switches the remote session to the GUI-less mode and does not display windows and controls. As a result, TestComplete (or TestExecute) will be unable to interact with the tested application’s GUI, as it does not exist and your automated GUI test will fail.
To work around the issue, you can change the Remote Desktop’s registry settings on your local computer (where you launch the Remote Desktop):
On your local computer, close all open Remote Desktop sessions.
Launch the Registry editor (regedit.exe).
Navigate to one of the following Registry keys, depending on whether you wish to modify the Remote Desktop settings only for the current user or for all users on the computer:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
Or you can do it programmatically by following steps:
Transparent the window
Restore the Window
Capture
Minimize it again
Remove transparency
We had similar problem in our project last year...we could find any stable and permanent solution....however here is how a work around worked for us...
We had to run on 5 remote desktops (which will take screens capture as well during failure) ..however as you have figured already if we disconnect session or minimise the RDC Window blank screenshot is captured. Therefore we had added one more VM to connect those other five test boxes. The task for that VM is to keep session active and resized to other 5 boxes...this worked for us.
If you connect a remote desktop to the test machine, make sure to reboot the machine when you are done, otherwise the desktop will remain locked and screen captures will not work.
I don't believe there is any other way around the issue.
I just configured the clients to auto logon, disabled the screen saver and installed a VNC server on each client.
Basically, make sure the screen is always on, and don't RDP into them.
This worked on both physical PCs and on virtual machines hosted on a Hyper-V server.
I even wrote a small .NET desktop client that ran multiple VNC clients inside a single window, so we could see what was happening on all the clients. We had an old PC running this with it's monitor on top of a cupboard to (a) let the developers see if any client had hung, had hundreds of browser windows open, etc. and (b) to look impressive for any non-developers walking past.
A simpler alternative to the above answers to to transmute the terminal session (RDP) into the console session. The session will then display to the physical screen (Switching the user of anyone currently logged into the physical machine). The following command does this:
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (tscon.exe %%s /dest:console)

Resources