Skip to content

Commit

Permalink
Add config file line parsing (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyk4j authored May 13, 2024
1 parent 3797940 commit a9249b8
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
45 changes: 42 additions & 3 deletions wsh/chcl3.vbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
Option Explicit

Const OPEN_READ = 1

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Function ReadTextFile(Path)
Dim Buffer
Set fh = fso.OpenTextFile(Path, 1)
Dim fh, Buffer
Set fh = fso.OpenTextFile(Path, OPEN_READ)
Buffer = fh.ReadAll()
fh.Close
Set fh = Nothing
ReadTextFile = Buffer
End Function

Sub ReadLine(Path, Callback)
Dim fh, Buffer
Set fh= fso.OpenTextFile(Path, OPEN_READ)
Do While Not fh.AtEndOfStream
Buffer = fh.ReadLine
'Remove comment
Dim SemiColon
SemiColon = InStr(Buffer, ";")
If Not IsNull(SemiColon) And SemiColon > 0 Then
Buffer = Left(Buffer, SemiColon - 1)
End If

'Split into tokens
Dim Tokens
Tokens = Split(Buffer)

If Not IsNull(Tokens) And IsArray(Tokens) And UBound(Tokens) > 0 Then
Call Callback(Tokens)
End If
Loop
fh.Close
Set fh = Nothing
End Sub

Function DisplayLicense()
Dim LicenseText
LicenseText = ReadTextFile("..\LICENSE")
Expand Down Expand Up @@ -41,6 +69,17 @@ Function DisplayWarning
DisplayWarning = MsgBox(WarningText, vbYesNo + vbExclamation + vbDefaultButton2, "Warning")
End Function

Sub StopService(Service)
WScript.Echo Service(LBound(Service))
End Sub

Sub StopServices
Dim SubRef
Set SubRef = GetRef("StopService")
Call ReadLine("services.txt", SubRef)
Set SubRef = Nothing
End Sub

Sub Main()
Dim Accepted
Accepted = DisplayLicense()
Expand All @@ -49,7 +88,7 @@ Sub Main()
Accepted = DisplayWarning()

If Accepted = vbYes Then
WScript.Echo "Continue..."
Call StopServices
End If
End If
End Sub
Expand Down
32 changes: 32 additions & 0 deletions wsh/services.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; Which Windows Services can you safely disable in Windows 11/10?: https://www.thewindowsclub.com/which-windows-10-services-safe-to-disable

dmwappushservice Device Management Wireless Application Protocol (WAP) Push message Routing Service
;AVCTP service
BDESVC BitLocker Drive Encryption Service
bthserv Bluetooth Support Service
Browser Computer Browser
;Connected User Experiences and Telemetry
DPS Diagnostic Policy Service
WdiServiceHost Diagnostic Service Host
WdiSystemHost Diagnostic System Host
DiagTrack Diagnostic Tracking Service
Trkwks Distributed Link Tracking Client
;Downloaded Maps Manager
;File History Service
IEEtwCollectorService Internet Explorer ETW Collector Service
iphlpsvc IP Helper
;Infrared monitor service
SharedAccess Internet Connection Sharing
Netlogon Netlogon
PcaSvc Program Compatibility Assistant Service
;Spooler Print Spooler
WPCSvc Parental Control
RemoteRegistry Remote Registry
seclogon Secondary Logon
lmhosts TCP/IP NetBIOS Helper
TabletInputService Touch Keyboard and Handwriting Panel Service
WerSvc Windows Error Reporting Service
stisvc Windows Image Acquisition
;Windows Camera Frame Server
;Windows Insider Service
WSearch Windows Search

0 comments on commit a9249b8

Please sign in to comment.