Skip to content

Instantly share code, notes, and snippets.

@hermesthecat
Forked from CHEF-KOCH/DisableSmartScreen.vbs
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save hermesthecat/c3b4bf0302be14426989 to your computer and use it in GitHub Desktop.

Select an option

Save hermesthecat/c3b4bf0302be14426989 to your computer and use it in GitHub Desktop.
'#---------------------------------------------------------------------------------
'#The sample scripts are not supported under any Microsoft standard support
'#program or service. The sample scripts are provided AS IS without warranty
'#of any kind. Microsoft further disclaims all implied warranties including,
'#without limitation, any implied warranties of merchantability or of fitness for
'#a particular purpose. The entire risk arising out of the use or performance of
'#the sample scripts and documentation remains with you. In no event shall
'#Microsoft, its authors, or anyone else involved in the creation, production, or
'#delivery of the scripts be liable for any damages whatsoever (including,
'#without limitation, damages for loss of business profits, business interruption,
'#loss of business information, or other pecuniary loss) arising out of the use
'#of or inability to use the sample scripts or documentation, even if Microsoft
'#has been advised of the possibility of such damages
'#---------------------------------------------------------------------------------
Const HKEY_LOCAL_MACHINE = &H80000002
Dim StrComputer,strKeyPath,strValueName
Dim objRegistry
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Policies\Microsoft\Windows\System\"
strValueName = "EnableSmartScreen"
objRegistry.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
Dim RegKeyPath
Set objShell = CreateObject("Wscript.Shell")
regKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\EnableSmartScreen"
'determine if a registry key exists
If IsNull(dwValue) Then
'if the registry key does not exist, create a new registry key
objShell.RegWrite regKeyPath,0,"REG_DWORD"
WScript.Echo "Turn off SmartScreen successfully."
Else
If dwValue = 0 Then
WScript.Echo "You have already turn off SmartScreen successfully."
Else
objShell.RegWrite regKeyPath,0,"REG_DWORD"
WScript.Echo "Turn off SmartScreen successfully."
End If
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment