S
S
Sergey2015-06-24 13:21:17
cmd/bat
Sergey, 2015-06-24 13:21:17

How to hide the shutdown buttons in windows 7+ through the command line (script)?

How to prevent users from shutting down or restarting a Windows 7 computer using a command line (script)?
I found an article on how to do this through gpedit.msc windowstips.ru/notes/847
But it's not clear how this can be done from a script.
Any version of bat, powershell, or code in any programming language (C# basic, etc.) will do.
The only important thing is that this must be done without restarting the computer. those. the variant with change of parameters of the register will not give a ride.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-06-24
@rooltak

I managed to solve the problem myself, through the registry :)
The meaning is this, we edit the registry parameters, then we pull gpupdate with the / force
key. I will give the code for solving my problem.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoClose"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoClose"=-

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoClose"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoClose"=-

@echo off
echo Wait please. Program is loading...
start /wait regedit.exe /s %~dp0remove.reg
start /wait /min gpupdate /force
cls
echo Program started. You can work.
start /wait mstsc.exe
cls
echo Wait please. Program is closing...
start /wait regedit.exe /s %~dp0add.reg
start /wait /min gpupdate /force

In my case, I optimized this solution a little more, I generate reg files from a bat script, after they work, I delete them.
Since if you do not run the script as administrator, it will display a query window every time you access the registry, and constantly right-clicking on the script and choosing to run as administrator is not very convenient, you can compile bat into an exe file. I used www.f2ko.de/en/b2e.php (although there might be better ones). In this utility, you can still attach your own icon.
As a result, I received an exe file with the icon I needed and a size of ~ 30kb.

D
des1roer, 2015-06-24
@des1roer

are you writing a virus?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question