How to create a script to disable the shutdown button on Windows 7

Solution 1:

Disable Shutdown, Restart, Sleep, and Hibernate Buttons

To open Local Group Policy Editor, click on Start and type in gpedit.msc and hit Enter.

In Local Group Policy Editor navigate to User Configuration \ Administrative Templates \ Start Menu and Taskbar and double click on Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands.

Now you want to enable this setting and click Apply and Ok. You can leave a note to yourself in the comment box, which I find comes in handy when changing a lot of settings in Group Policy.

Now when you look at the Power options in the Start Menu, the only options available are Log off, Switch user, and Lock.

The setting goes into effect right away for all users of the machine. The button to turn off the computer if the user hits Ctrl+Alt+Del will be gone as well.

Source

Solution 2:

Windows shut down, restart, sleep and hibernate are controlled by one .exe file: %windir%\system32\shutdown.exe

So as you want to do this from a command line and not a GPO we need to use the only tools we have at our disposal Command Prompt:

icacls %windir%\system32\shutdown.exe /deny SID:D

This will remove their access to the shutdown command and they will not be able to execute a shutdown.