Sao bạn không dùng Start/Run/msconfig/Enter rồi tắt các chức năng dịch vụ của Window được ah? Mà phải dùng VBA trong Excelem tìm trên diễn đàn mình nhưng chưa thấy có , bác nào chỉ giúp em cách dùng vba để bật , tắt ... các dịch vụ của window , cảm ơn !
Bạn dùng code này:em tìm trên diễn đàn mình nhưng chưa thấy có , bác nào chỉ giúp em cách dùng vba để bật , tắt ... các dịch vụ của window , cảm ơn !
Sub ServiceAction(ByVal ServiceName As String, ByVal isStart As Boolean)
Dim sComm As String
sComm = IIf(isStart, "net start ", "net stop ") & """" & ServiceName & """"
Shell (sComm)
End Sub
Sub Main()
Dim ServiceName As String
ServiceName = "Print Spooler"
ServiceAction ServiceName, [COLOR=#ff0000][B]True[/B][/COLOR]
End Sub
Sub Main()
Dim ServiceName As String
ServiceName = "Print Spooler"
ServiceAction ServiceName, [COLOR=#ff0000][B]False[/B][/COLOR]
End Sub
cảm ơn bác nhé, code tuyệt lắm , chạy rồi !
Sub WinSvrList()
Dim lR As Long, ObjSvr As Object
With Range("A1:C1")
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Cells(1, 1) = "Display Name"
.Cells(1, 2) = "Service Name"
.Cells(1, 3) = "Status"
End With
lR = 1
With GetObject("winmgmts:\\.\root\cimv2")
For Each ObjSvr In .ExecQuery("Select * From Win32_Service")
lR = lR + 1
Cells(lR, 1) = ObjSvr.Caption
Cells(lR, 2) = ObjSvr.Name
Cells(lR, 3) = ObjSvr.State
Next
End With
With Range("A1:C1").CurrentRegion
.EntireColumn.AutoFit
.Sort .Cells(1, 1), 1, , , , , , xlYes
End With
End Sub