Tuesday, July 20, 2010

Disable Smart Card in Windows VBS

This piece of code allows you to log onto a Smart Card Computer with your Windows Log On. This allows you to log on just once, then will reset after GPO refreshes.  This script essentially mods the registry entry. Please view below:


On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002


set objShell = wscript.createobject("wscript.shell")
strComputer = Wscript.Arguments.Item(0)
If strComputer = "" Then strComputer = InputBox("Enter Computer name to Disable:", "CCL Disable")
If strComputer <> "" Then
    Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
   strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
    strEntryName = "SCForceOption"
    dwValue = 0
    objReg.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strEntryName, dwValue
    
    If (Err.Number = 0) or (Err.Number = 9) Then 
   wscript.echo strComputer & " SUCCESS! "& vbCrLf & "Smart Card Access Not Required Now" & _
            vbCrLf & 
"Upon login a GPO will reset the computer to Smart Card only." 
Else If (Not Err.Number = 0) or (Not Err.Number = 9) Then 
   wscript.Echo "Error: "& vbCrLf & strComputer & " not found or no access.."
     End If
     End If
End If

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...