管理和優化服務的vbs

2021-04-13 08:32:09 字數 2879 閱讀 5041

dim ss, s

dim szmsg, szttl

dim l

set ss = getobject("winmgmts:").execquery("select * from win32_service")

szmsg = "執行了下列操作:" & vbcrlf

szttl = "管理服務程式"

l = len(szmsg)

for each s in ss

select case ucase(trim(s.name))

case "dfs":

call stopmanual()

case "ersvc":

call stopmanual()

case "helpsvc":

call stopmanual()

case "mdm":

call stopmanual()

case "messenger":

call stopdisable()

case "spooler":

call printspooler()

case "remoteregistry":

call stopdisable()

case "schedule":

call stopmanual()

case "themes":

call themes()

case "audiosrv":

call windowsaudio()

case "w32time":

call stopmanual()

end select

next

set ss = nothing

set s = nothing

if len(szmsg) = l then szmsg = "您的服務設定和本程式預期的一樣!"

msgbox szmsg, 4160, szttl

'distributed file system

'error reporting service

'help and support

'machine debug manager

'task scheduler

'windows time

sub stopmanual()

dim b***

b*** = false

if strcomp(s.startmode, "manual", 1) then

s.changestartmode("manual")

b*** = true

end if

if strcomp(s.state, "stopped", 1) then

s.stopservice

b*** = true

end if

if b*** then szmsg = szmsg & vbcrlf & "停止" & s.caption & "服務,並將其啟動型別設為手動。"

end sub

'messenger

'remote registry

sub stopdisable()

dim b***

b*** = false

if strcomp(s.startmode, "disabled", 1) then

s.changestartmode("disabled")

b*** = true

end if

if strcomp(s.state, "stopped", 1) then

s.stopservice

b*** = true

end if

if b*** then szmsg = szmsg & vbcrlf & "停止並禁用了" & s.caption & "服務。"

end sub

'print spooler

sub printspooler()

if strcomp(s.state, "stopped", 1) or strcomp(s.startmode, "manual", 1) then

if msgbox("您是否有印表機?", 4132, szttl) = 7 then

s.changestartmode("manual")

s.stopservice

szmsg = szmsg & vbcrlf & "停止並禁用了" & s.caption & "服務。"

end if

end if

end sub

'themes

sub themes()

if strcomp(s.state, "stopped", 1) or strcomp(s.startmode, "manual", 1) then

if msgbox("您是否要使用 xp 主題風格?", 4132, szttl) = 7 then

s.changestartmode("manual")

s.stopservice

szmsg = szmsg & vbcrlf & "停止並禁用了" & s.caption & "服務。"

end if

end if

end sub

'windows audio

sub windowsaudio()

if strcomp(s.state, "running", 1) or strcomp(s.startmode, "auto", 1) then

s.changestartmode("automatic")

s.startservice

szmsg = szmsg & vbcrlf & "自動啟用了" & s.name & "服務。"

end if

end sub  

Redis的記憶體管理和優化

used memory 已經使用了的記憶體大小,包括redis程序內部開銷和你的cache的資料所占用的記憶體,單位byte。used memory human 以可讀格式返回的used memory。used memory rss 從作業系統角度顯示的redis占用的物理記憶體。used memo...

HIVE許可權管理和優化

1 storage based authorization in the metastore server 基於儲存的授權 可以對metastore中的元資料進行保護,但是沒有提供更加細粒度的訪問控制 例如 列級別 行級別 2 sql standards based authorization in...

Mysql優化和web伺服器優化

1 提高併發量 負載均衡 分布式服務架構 併發量更高的軟體例如nginx 2.頁面靜態化 不經常發生資料變動的動態網頁生成靜態網頁,提高訪問速度 3.記憶體快取優化 把資料快取到記憶體中,提高資料相應速度 4.資料庫優化 一般資料讀寫頻繁,可以快取到記憶體中。但是記憶體容量有限,不能夠把大量資料快取...