How to turn screensaver on (windows 7) by a code (in cmd)?
相关问题
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
- I want to trace logs using a Macro multi parameter
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- CosmosDB emulator can't start since port is al
- How to print to stdout from Python script with .py
- Determine if an executable (or library) is 32 -or
Putting together the
cmd
andvbs
script ideas with the code from the answer to Launch System Screensaver from C# Windows Form I came up with the following:To build it, install the .NET Framework, copy and paste the above code into
lock.cs
, then run:Put the created
lock.exe
in your path, after that, typinglock
should engage the configured screen saver and lock your workstation.This works - only downside is that u cant interact with pc for something like 7 sec, but i guess its 7's to give ppl time before making screensaver 'permanent'.
You could try Powershell Script To Start A Random Screen Saver.
I have Windows 7. I placed the line:
@start /wait %windir%\ExtraPath\ScreenSaverName.scr /s & rundll32 user32.dll,LockWorkStation
in a batch (.bat) file, place it in a appropriate dir, and created a shortcut pointing to this, with the desired shortcut key. In this line, \ExtraPath is the additional path under your win dir (usually this is \system32) where the screen savers are located, and ScreenSaverName.scr is the name of the desired screen saver itself.
It works perfectly.
Now I can press the shortcut keys to run the screen saver and lock the pc.
Thanks really a lot.
Does the following meet your requirements?
As long as the
.scr
is on the PATH the above command should work.EDIT: I don't know if Windows 7 comes with
logon.scr
, make sure you're testing it with a.scr
that is actually installed in Windows 7.Note that I got the idea of just invoking the
.scr
with/s
from Screensaver Sample Command Line Options:EDIT 2:
I did some additional searching and found that you could create
lock.cmd
:Or
lock.vbs
: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.
It may not be possible to reproduce the system behaviour of starting the screen saver and password protecting on resume. Even the answer to Launch System Screensaver from C# Windows Form only starts the screen saver, it does not password protect on resume.