40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
from setuphelpers import *
|
|
import re
|
|
|
|
uninstallkey = []
|
|
|
|
def install():
|
|
print("Enabling SMBv1")
|
|
|
|
print('Checking SMBv1 state')
|
|
smbv1_status_enabled = run_powershell('Get-WindowsOptionalFeature -Online -FeatureName smb1protocol | out-string -stream | select-string "Enabled"')
|
|
|
|
if smbv1_status_enabled:
|
|
print('SMBv1 already enabled. No reboot required.')
|
|
exit
|
|
else:
|
|
run_powershell('Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart')
|
|
run_powershell('Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol-Deprecation -NoRestart')
|
|
print('Turn ON SMBv1 : %s' % (smbv1_status_enabled,))
|
|
print('Done, SMBv1 is now enabled. Reboot is required.')
|
|
exit
|
|
|
|
|
|
def uninstall():
|
|
|
|
print("Disabling SMBv1")
|
|
|
|
print('Checking SMBv1 state')
|
|
smbv1_status_enabled = run_powershell('Get-WindowsOptionalFeature -Online -FeatureName smb1protocol | out-string -stream | select-string "Enabled"')
|
|
|
|
if smbv1_status_enabled:
|
|
run_powershell('Disable-WindowsOptionalFeature -Online -FeatureName smb1protocol -NoRestart')
|
|
run_powershell('Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol-Deprecation -NoRestart')
|
|
print('Turn OFF SMBv1 : %s' % (smbv1_status_enabled,))
|
|
print('Done, SMBv1 is now disabled. Reboot is required.')
|
|
exit
|
|
|
|
else:
|
|
print('SMBv1 already disabled. No reboot required.')
|
|
exit |