mansz81

Reset_Local_Group_Policy.vbs

Mar 26th, 2022
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. If WScript.Arguments.Count = 0 Then
  2.     Set objShell = CreateObject("Shell.Application")
  3.     objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1
  4. Else
  5.  
  6. set winsh = CreateObject("WScript.Shell")
  7. set winenv = winsh.Environment("Process")
  8. windir = winenv("WinDir")
  9.    
  10. strPath = (WinDir & "\System32\GroupPolicy")
  11.  
  12.     DeleteFolder strPath
  13.  
  14.     Function DeleteFolder(strFolderPath)
  15.     Dim objFSO, objFolder
  16.     Set objFSO = CreateObject ("Scripting.FileSystemObject")
  17.     If objFSO.FolderExists(strFolderPath) Then
  18.     objFSO.DeleteFolder strFolderPath, True
  19.     End If
  20.     Set objFSO = Nothing
  21.     End Function
  22.  
  23. strPath = (WinDir & "\System32\GroupPolicyUsers")
  24.  
  25.     DeleteFolder strPath
  26.  
  27.     Function DeleteFolder(strFolderPath)
  28.     Dim objFSO, objFolder
  29.     Set objFSO = CreateObject ("Scripting.FileSystemObject")
  30.     If objFSO.FolderExists(strFolderPath) Then
  31.     objFSO.DeleteFolder strFolderPath, True
  32.     End If
  33.     Set objFSO = Nothing
  34.     End Function
  35.  
  36. winsh.Run "gpupdate /force", 0
  37.  
  38. End If
Advertisement
Add Comment
Please, Sign In to add comment