gnome disable "Log in as another user" link - centos

In Gnome on Centos 7, does anyone know how to disable "Log in as another user" on the lock screen? I can disable user switching using:
disable-user-switching=true
I achieve this be adding:
/etc/dconf/db/local.d/00-user-switching
[org/gnome/desktop/lockdown]
# Prevent the user from user switching
disable-user-switching=true
/etc/dconf/db/local.d/locks/lockdown
# Lock this key to disable user switching
/org/gnome/desktop/lockdown/disable-user-switching
This works nicely preventing the user switching option, but you can still switch users via the lock screen .
The reason as to why I'm doing this is because we're implementing a VNC recording solution. If a second person logs in, they are on a different display and therefore, VNC does not present that display to the client trying to record the screen as the original user stays on display 0 and the new user logged in is on display 1.
e.g.
[support#mymachine ~]$ who
fred :0 2018-09-26 08:27 (:0)
jenny pts/0 2018-09-28 09:43 (192.168.1.3)
pete :1 2018-09-28 08:13 (:1)
So what happens is that Fred logs locks his screen, Jenny clicks on "Log in as another user" and logs in which is fine, but it does not log Fred out. She therefore generates a new display and when you try and VNC, we can only see Freds original lock screen on Display 0 because Jenny has a new Display on 1.

Disable autospawning secondary VTs
In /etc/systemd/logind.conf set these two lines:
NAutoVTs=2
ReserveVT=2
Note that systemd wants logind to always have one VT reserved for TUI login. Setting both values to =1 overrides gdm's ability to spawn on VT1. Cf. systemd for Administrators, Part XVI at the systemd designer's blog.
After reboot, you have VT1 running gdm, and VT2 reserved for TUI login. "Log in as another user" cannot spawn another VT.
Note: this might be a useless answer since it doesn't prevent Xwayland systems (EL8) spawning the login window (on my test box at :1024). Even on EL7 it might not prevent gdm from trying to find another VT. In which case it's a bug in either gdm, or in the Gnome screenlock.

Related

VBS: Word.Documents.Open fails unattended [duplicate]

I have an Access VBA macro that generates a report, saves it in .pdf and then sends it by e-mail using CDO. Everything works fine if I run it manually or if I set it to be run on Task Scheduler with the security option "Run only when user is logged on". However, if I set the option to "Run whether user is logged on or not" (even with the option "Run with highest privileges") the program crashes on the second line of:
strFileFullPath = CurrentProject.Path & "\Test Report.pdf"
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, strFileFullPath
with the error
Microsoft Access can't save the output data to the file you've
selected.
I am pretty sure that this happens because the macro runs with other user in the background. I have been searching for a solution but all I have found is that it is not possible and that I should change for other printing methods, such as PDF Creator (which brings a lot of other issues).
I am using Access 2016 in Windows Server 2012 R2 Standard.
It sounds crazy, but after a few days with no results, I managed to solve my problem just by creating these two empty folders:
C:\Windows\System32\config\systemprofile\Desktop
C:\Windows\SysWOW64\config\systemprofile\Desktop
All the credits to Faye's comment on the bottom of this page: https://blogs.technet.microsoft.com/askperf/2015/02/18/help-my-scheduled-task-does-not-run/
Although the comment regards Excel, it solved my issue on Access. It seems that is related with Office having trouble with running some processes (in my case, a pdf generation) in non-interactive mode (which is the mode that Task Scheduler runs when "Run whether user is logged on or not" is checked).

How to set default printer for new users using powershell

Have a question on how to set the default printer for NEW users via powershell.
I have seen many posts about setting the default printer via the wmi method. This seems to work only for the currently logged in user that is running it. This will not work for other users that may have already logged in. I can set the default printer for user sid already in the profile list in the registry via HKU:\<SID>\Software\Microsoft\Windows NT\CurrentVersion\Windows key. I set the device string to the printer name and port, isMRUEstablished i set to 0 and legacydefaultprintermode i set to 1 to prevent windows from setting the last used printer as default. This seems to work for any users that have already logged on. Issue is i cant seem to find a way to set it system wide. If install the printer and set it up before the user gets the machine and logs in for the first time it wont be set for them. I have tried making the above mentioned registry changes to the .defualt user registry hive but when a new person logs into that machine they have something like webex document print set to the default or onenote printer or something else. Is there any other way to set via powershell so it will apply to a new user that logs on?
You have to load the hive from the default profile found in c:\users\default and called ntuser.dat.
After loading this hive make the reg setting as needed. Then unload the hive. Now anyone who logs in to the system for the first time will get those settings, whatever they are, by default. The .Default in the registry is what runs when the system is at login but not yet logged in so no effect for printer settings.

How to synchronize system date/time?

How to synchronize system date/time with the date/time on workstation in Windows 7? I am trying to use ADO.Net from devArt to connect to Oracle DB from Windows CE (Compact Framework). I want to use 30 days trial to test it before I buy it.
I am getting this error:
Sorry, your trial period has expired.
Support:
The possible reason may be that the system date/time of the device is
not synchronized with the date/time on your workstation; hence, the
issue can be resolved by setting the same date/time as set on the
workstation.
Please refer to http://windowstipoftheday.blogspot.cz/2010/03/windows-7-automatically-syncronzing.html
FTA:
In the Start menu search field type "Date and Time" and press Enter, this should be bring the Date and Time control panel
In the Date and Time dialog box, click the Internet Time tab.
Press the Change Settings button. Press the Continue button in the User Account Control dialog box (if it displays).
In the Internet Time Settings dialog, click the Server drop-down arrow and select another time server. The default is time.windows.com, try using time.nist.gov and see it works for you.
Press the Update now button to update your computer's clock, and test your computer's
Press the OK buttons close the dialog boxes.
For users with domain accounts, try using this command line command: w32tm /config /syncfromflags:MANUAL /manualpeerlist:time.nist.gov w32tm /config /update (thanks to #user6852928 for this).

Automatic-control-question

How can I create a program that controls my computer based on commands which I have entered ahead of time.
For example:
My application should at 6pm enter facebook, enter my user credentials to log me in, and then leave a comment in the comment field which I have entered at 1PM.
Told means commend that I stored in this software.
My background is c++ and I realize programming philosophy since I program in machine language-I'm electrical engineer.
Thanks
Is this just for your own personal usage?
If so, I would advise not actually trying to develop an application yourself for this but instead use a Macro program. About 8 years ago when I was extremeley inexperienced at programming or doing anything, I used some macro programs to create bots in games, so doing something as trivial as logging you in would be simple.
Just have it..
Launch C:/Program Files/Mozilla/Firefox.exe (or something similar)
Press F6
Type: "http://www.facebook.com"
Press ENTER
Check pixel at local XXX x YYY to see if you are already logged in, in which case you don't need to enter your username and password
If you are not logged in, move mouse to coords XXX and left click.
Type username
Repeat for password.
Press ENTER
Navigate to profile.
Check the time on your system. If time is not 1PM, wait one minute and try again.
Repeat above.
Time is now 1PM so post your message.
End macro.
You could make that using a program like Macro Express within about 10 minutes. It also has a Capture editor, so that you can record your own macro and then edit it as you require.
http://www.macros.com/
This answer obviously assumes it is for personal usage.

How to run my program on before logout on windows XP?

I am looking for an inverse version of "RunOnceEx".
RunOnceEx does run some program, before the user's shell(desktop&taskbar) start. The login progress will not continue before the runonceex complete.
I want to do exact the same but on user logout.
When she/he logout, all running program shutdown, leaving shell(desktop&taskbar), then ""I wish my program will be execute this moment"", finally logout.
I think it is possible because the "mobsync.exe" is doing that. But I cannot find where and how to do it.
Warning, as said here, gpedit.msc will allow you to configure a logoff script for all users.
If you need that script only for one user, you need to declare it directly in the registry, both in HKCU and HKLM.
To run this only for the current user, you can use WMI to get an information when a shutdown/logout occurs.
Either you write a small C# (or any other language that can use WMI) application or vbs script to listen on the Win32_ComputerShutdownEvent WMI event.
An example C# app can be found here in this question: Get Log off event from system
found in the first result on google for me
To execute a program you can create a script to run it and use group policy to enforce it.
In Group Policy Editor navigate to User Configuration-->Windows Settings-->Scripts (Logon/Logoff)
more information here
If you want a running program to execute code on logoff, then you should hook the WM_QUERYENDSESSION message and look for an lParam value of ENDSESSION_LOGOFF (0x80000000).
It's important to test for this lParam value because the other ones indicate a "forced close" - i.e. your process may be killed before your code is even allowed to run. In fact, most shutdown/session-end messages are only intended to give you an opportunity to run last-minute cleanup code and aren't that safe to respond to with long-running actions; but this particular combination should be OK.
Note: I've never tried to actually run a separate process in response to the WM_QUERYENDSESSION message. It's possible that the window manager will disallow this, like it does during shutdown. Try it and see, I guess.
If you're in a .NET environment (you didn't specify), a quicker way is to add an event handler to the Microsoft.Win32.SystemEvents.SessionEnding event.
What you need is an implementation of GINA. You can run your custom commands in WlxIsLogoffOk function, which gets called when the user initiates a logoff
Once you create the proper GINA dll you can register it here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\#GinaDLL
Here is an implementation which may fit your needs (it provides a Logoff registry key where you could specify your command):
http://wwwthep.physik.uni-mainz.de/~frink/newgina_pre09/readme.html
As VonC and TFD already mentioned, the Group Policy Editor is just another way to manipulate the registry.
Just make with gpedit the changes (in Userconfig - Windows Settings - Scripts) you like and afterwards take a look in the registry at [HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]
to find out how you can do that directly.
Also on my PC (hanging in a domain) is a hidden folder C:\WINDOWS\System32\GroupPolicy with subfolders for user and machine. Both having additional subfolders called Shutdown and Startup. Maybe you can also use these ones.
If you need something simple and working for a single (or any) user you can make a simple application in C++ or C# for example.
The simplest is having a C# in tray (by simply adding the tray component to the form) and register and event handler for the FormClosing event. It'd look like this:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.UserClosing)
{
// It's not the user closing the application,
// Let's do whatever you want here, for example starting a process
Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
notePad.Start();
}
}
So your application will be started with Windows or with the user. It'll wait (using a little bit of memory) and will do something when the system shuts down, or the user log off, etc (by checking "CloseReason" above).