how to make a vbscript do something when a program is open

91 Views Asked by At

So What I need is for when cmd.exe is open run a MsgBox and close cmd.exe
such as:

' Code for when cmd.exe loads
MsgBox("Command Prompt Disabled")
' closes command prompt

Thanks!

I need actual code

1

There are 1 best solutions below

0
On

Don't use a vbscript to do this.... use a GPO.. because if someone disables that script your security control is broken.

If you're editing for a single user/single machine...

It might be faster to write a registry vb script or batch file with your control instead of using a GPO for each user you don't want using it. Create the system key if system does not exist in the Windows Key. The Caveat, is you have other controls that won't prevent disabling this with about 5-minutes of Google Searching.

reg add "HKCU\Software\Policies\Microsoft\Windows\System"
reg add "HKCU\Software\Policies\Microsoft\Windows\System" /t REG_DWORD /v DisableCmd /d 2

Using Gpedit or OU-Level assigned policies for Non-Admins

User configuration\Administrative Templates\System\Prevent access to the command prompt

Other policies to consider adding to Non-Admin User groups.

User configuration\Administrative Templates\System\Prevent access to registry editing tools
User configuration\Administrative Templates\System\Don't run specified Windows Applications