Completely locking down Windows 7 using Python 3.2? - winapi

This might be a more difficult question since I don't even know how to do it outside of Python...
I want to write a terminal program that completely locks up my PC until a password is entered. In the locked state no one should be able to do anything outside the terminal. In it, the user may rampage and write silly commands, but he should not be able to switch windows, click outside of it, open the task manager, open the menu with Ctrl + Alt Gr + Del and so on.
While searching for a way to accomplish this I've thought of two approaches that Python is also able to do:
Modifying the registry -> can disable task manager and some other functions, but not the app switcher neither the menu
Task-killing explorer.exe and dwm.exe -> killing explorer.exe just removed the taskbar, killing dwm.exe seems like the right way, but as it's the window manager it automatically boots up itself again as soon as it gets killed
I know this is a kind of weird question and doesn't contain any code snippet, but the front-end is no problem and as said I don't even got a working approach for the back-end.

write a while loop
Into the while loop write the command to taskkill dwm.exe
It's a poor solution, but the only one I know.
Regards!

Related

why does command window opens then close then open another window

I know this question looks like dozen of others: but, I am trying to get insight into why this script acts the way it does and if there is any draw back to it like memory leak or other.
The script its simple:
cd "C:\me\python\.venv" && start C:\me\python\.venv\env\Scripts\activate
There is a windows that opens briefly then closes then another command window opens with the virtual environment open as I need. This question is not about the virtual environment in any way. I am trying to understand the command window.
It seems buggy that a command window opens to change directories then closes and then another opens the virtual environment in another window. I can live with this I guess until I run across a seemless way to do this; but, isn't there a better way to do this?
Is the window opening then closing the behavior of the command prompt when changing directories? No! The script could be written simply as:
start C:\me\python\.venv\env\Scripts\activate
and there is still an occurence of a window opening prior to the window with the virtual environment started.
Is there any after affects from doing it this way, like background process open or memory leak or what have you?
Anyone know where to read the "readme" on this behavior?
Thank you much!
Use this code:
cd "C:\me\python\.venv" && C:\me\python\.venv\env\Scripts\activate
the start command is not necessary and that's what opens one more window and lets the previous one close.
This command create a new windows asynchronously.

Windows 10 Search after first press of Control-Escape not working, Cortana disabled in policy/registry

This is a unique problem I have and I've searched and am unable to find a solution. This is on Windows 10, with latest updates, as of up to 9/28/2017, for the past few months. I have disabled Cortana via registry and policy. If after using system for a bit (say, 10+ seconds), and I hit Control-Escape, it brings up the start menu. Search never works. I'm a touch typist so this is really annoying. I want to hit Control-Escape and start typing my search, which works fine on other people's computers.
For example, to run cmd.exe, my typing is "Control-Esc,c,m,d,Enter". On my system, search doesn't come up and my c,m,d keystrokes don't go anywhere. I have to wait a second, then redo this, and it will work. I don't have a Run key, and I'm really used to this Control-Escape, then start typing method, and ideally would like to keep using it.
One "solution" I've found is that if I taskkill Cortana, it stays killed for a bit (like 10-15 seconds?), then comes back. If I taskkill Cortana, then hit control-esc within a few seconds, search always works. My temporary "solution" is to use auto-hotkey, and this script:
^Esc::
Process,Close,SearchUI.exe
KeyWait Esc
KeyWait Ctrl
Send {LWin}
Return
This intercepts the control-esc sequence, and kills Cortana instead, then waits until control and escape keys are released, then presses windows key (found this tip in another stackoverflow question/answer).
Anyone have any other ideas how to fix this, or what causes it? My guess is Cortana is somehow trying to do something and it's timing causes search to fail. Thanks!

How do I pause a vlc process from the command line? [duplicate]

Well i have an adobe air which runs vlc-player at background as service. i check that in Windows Task Manager , the service runs when air application launches.
here is the code
processArgs.push("--extraintf");
processArgs.push("rc"); //Remote control
processArgs.push("--rc-fake-tty"); //Use terminal as output
processArgs.push("screen://");
processArgs.push(":screen-fps=15");
processArgs.push(":screen-caching=100");
processArgs.push(":sout=#transcode{venc=x264{bframes=0,nocabac,ref=1,nf,level=13,crf=24,partitions=none},vcodec=h264,fps=15,vb=3000,width=800,height=600,acodec=none}:duplicate{dst=std{mux=mp4,access=file,dst='"+targetFile.nativePath+"'}}");
startupInfo.arguments = processArgs;
p = new NativeProcess();
p.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
p.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
p.addEventListener(NativeProcessExitEvent.EXIT, onExit);
now i want to close vlc-player on the button click event and i have searched the vlc- documents and found quit command and its syntax, it does not work as i have tried that syntax from windows command prompt also..
Which are the vlc-player commands that can pause,stop and close vlc-player??
Any useful link will be much helpful to me..
I've had quite a look around and looks like this (--rc-fake-tty) can't be done from Windows command line. Which means your current approach is out.
I don't no anything about Adobe but I have done some searching around and this guy has something written in C using the libVLC. Not sure if that will help or point you in the right direction.
The other thing I found was this post Adobe Air and VLC player which mentions that you should be able to use javascript and ActiveX controls on Windows. A guy in this forum has a javascript script which uses an ActiveX control to start, stop, pause etc.
There is a VLC command that you can send to override or set certain hotkeys. Search for next, prev, stop, quit, vol-up, etc in this document.
That's the best of my Googling abilities, hope it helps.
I dont want to agree that your code runs well on windows, becasue --rc-fake-tty will not run on windows, to hide the entire vlc window (it will be listed among the processes in Windows Task Manager) use --rc-quiet but to see command window use --no-rc-quiet.
To stop and quit using p.standardInput.writeUTFBytes("stop" + "\n"); is not working for me as well.

Update desktop "show window contents while dragging" setting programatically

One of my programs seems to be changing the Display Properties > Appearance > Effects > Show window contents while dragging setting to off every few hours.
I'm not sure exactly which program, or when it happens. I have a number of programs that seem like likely culprits - wallpaper rotators, software for multiple monitors, multiple virual desktops and switching, and a few others.
I am just thinking to create a little batch script to run periodically and set the setting back to on.
Does anyone know how to do this in windows? I'm using xp pro sp3.
Thanks!
The best option is to do this programmatically using the supported API. i haven't tested this, but it should do the trick:
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS,
TRUE,
NULL,
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
You can use SPI_GETDRAGFULLWINDOWS to see if the the bit has been flipped to avoid unnecessarily triggering a WM_SETTINGCHANGE.
You can use RegMon to find the program that keeps changing your settings. Maybe that's a better start than hacking around it.
There is a simple and effective solution to this problem. In Notepad type the following lines :
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Desktop] "DragFullWindows"="1"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects\DragFullWindows] "CheckedValue"=dword:00000001 "UncheckedValue"=dword:00000001
Save the file as "Show Window Contents.reg" Double clicking this file and restarting will cure the problem permanently. Post a message if you find this useful.
Aravind Banerjee
It seems the registry setting which controls that preference is HKCU\Control Panel\Desktop\DragFullWindows. You can read more about it here. However, trying it on my own computer does not register the change right away, so a batch script won't do it. You'll probably have to write a program to manipulate it using SystemParametersInfo(). You can pass it the SPI_SETDRAGFULLWINDOWS parameter. Here's a page explaining it more. Here's a page showing how to call it, albeit not for the same parameter.
I suspect it's kept in the registry - maybe [HKEY_CURRENT_USER\Control Panel\Desktop] - "DragFullWindows"?
It would be easy to flip the registry setting back to "1" every hour or so with a batch file.

Clearing the Windows "Run" dialog history without rebooting

I am currently working on a program to immediately clear the list of previously-run-commands which appears in the Windows Start -> Run dialog. The procedure for clearing this list by removing the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU key is well documented; however, before these changes take effect, it seems to be necessary to do one of the following:
Restart the computer
Select Start -> Shut down, and then select Cancel.
Neither of these is ideal for the task I am trying to accomplish: #1 is extremely disruptive to the user, and #2 appears to require additional user interaction.
Does anyone know how to immediately (and programmatically) force a reload of this information without requiring any user interaction, while also minimizing disruption of the user's other activities? I would like for the user's Run history to be cleared out immediately after executing my program, without requiring any further action on their part (such as using the "Shut Down" -> "Cancel" trick in #2 above) or forcing a reboot.
Or, to approach the problem from a different angle: When clicking Start -> Shut Down -> Cancel, Windows Explorer reloads the RunMUI key. Is there a way to force a similar reload without having the user select Shut Down and then Cancel?
Things I have already tried:
Monitoring the explorer.exe status using procmon while selecting Shutdown and then Cancel. I see Explorer writing to the RunMRU key, but have not been able to determine what triggers this.
Numerous Google searches along the lines of "reload runmru without reboot". Most results still recommend method #1 above, although a few suggest #2.
Limited MSDN API examination. The RegFlushKey call appears promising, but I haven't ever used it before, so I don't know if it will apply to registry information cached by different processes.
Any suggestions or other information would be greatly appreciated.
Have you tried ccleaner?
http://www.ccleaner.com/
Not a full answer to your question, but I did find a third way to trigger the clearing of the run command from this article in PC Mag.
Killing explorer.exe and then restarting it will also clear the run list after the registry modification.
I have a nasty hack for you. Show the window programatically, hide it immediately (programatically) and click cancel on it (well, you guessed, programmatically).
You might try looking for the icon cache flush API, or other ones, I wouldn't be too suprised if they had side effects like the one you are looking for.
I've seen instances where it actually works, even the F5 key doesn't work? Try this, ctrl>alt>delete then go to task manager, processes tab...end explorer.exe. Then click on file new task and type explorer.exe, then check...does that work?
Windows XP
Right click on the taskbar
Properties menu option
Start Menu tab
Customize button
Programs pane
Clear List
Click on OK
This calls a Windows API function that refreshes the explorere.exe taskbar process and also clears the list (no need for registry edits).
As far as I know, it relies on the explorer.exe process that hosts the start menu/taskbar/desktop being closed and reopened. There is no "clean" way to do this that I am aware of.
If you really need to do this without user interaction, you need to close all explorer.exe processes and relaunch one.
Here's a rudimentary C# program to do that;
using System.Diagnostics;
Process[] procs = Process.GetProcessesByName("explorer");
foreach (Process proc in procs)
{
proc.Kill();
}
Process.Start("explorer.exe");
Note that this will close all "Windows Explorer" windows open, and may or may not open an additional "Windows Explorer" afterwards.
I just tested that on Windows XP 32bit, and it did indeed clear the Run command cache.
HKEY_CURRENT_USER\ Software\ Microsoft\ Windows\ CurrentVersion\ Explorer\ RunMRU\

Resources