industriesrefa.blogg.se

Make screensaver start windows 10
Make screensaver start windows 10






make screensaver start windows 10

Having a 1/4 century of bash experience, powershell is very strange, but also a bit refreshing to work with. ( Learn more here.) A slightly less convenient alternative is Get-Member. Unfortunately, installing it now requires the -AllowClobber option. (I have to admit that even though I can write sed directly into a script without testing it at the CLI, this IS better.) There is a useful tool for exploring objects that is recommended by a Microsoft technet blogger. We access a single property with the convenient dot notation. Here, the Get-ItemProperty returns an object that has many properties. This is a pretty succinct demonstration of how powershell returns objects (complete with methods, accessors, etc.) rather than streams of text like bash.

make screensaver start windows 10

That value just happens to be a complete path to a *.scr file, and therefore you can (and I do) tell powershell to run it as a command. This will get the value of the SCRNSAVE.EXE property from the registry. Powershell.exe -command "& (Get-ItemProperty 'HKCU:Control Panel\Desktop')." # This works from both WSL/bash and powershell! Put the created lock.exe in your path, after that, typing lock should engage the configured screen saver and lock your workstation.To make this a legitimate SO answer, I'll include the simpler one: #!/bin/bash NET Framework, copy and paste the above code into lock.cs, then run: %SystemRoot%\Microsoft.NET\Framework\v3.5\csc.exe lock.cs SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0) Public static void SetScreenSaverRunning() Private const int WM_SYSCOMMAND = 0x0112 Private const int SC_SCREENSAVE = 0xF140 Private static extern IntPtr LockWorkStation() Private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam) Private static extern IntPtr GetDesktopWindow() Putting together the cmd and vbs script ideas with the code from the answer to Launch System Screensaver from C# Windows Form I came up with the following: using System Even the answer to Launch System Screensaver from C# Windows Form only starts the screen saver, it does not password protect on resume. It may not be possible to reproduce the system behaviour of starting the screen saver and password protecting on resume. Neither of these answers is perfect, both reveal a flicker of the desktop after the screen saver is disabled and just prior to the workstation being locked. ObjShell.Run "rundll32.exe user32.dll,LockWorkStation" ReturnVal = objShell.Run("logon.scr", 1, True) ' The "True" argument will make the script wait for the screensaver to exit Or lock.vbs: Set objShell = CreateObject("Wscript.Shell") I did some additional searching and found that you could create lock.cmd: /wait logon.scr /s & rundll32 user32.dll,LockWorkStation /p # – Display a preview of the screensaver using the specified./c – Show the configuration settings dialog box./s – Start the screensaver in full-screen mode.scr with /s from Screensaver Sample Command Line Options: Note that I got the idea of just invoking the. scr that is actually installed in Windows 7. scr is on the PATH the above command should work.ĮDIT: I don't know if Windows 7 comes with logon.scr, make sure you're testing it with a. Does the following meet your requirements? start logon.scr /sĪs long as the.








Make screensaver start windows 10