Shout !


Free shoutbox @ ShoutMix

BlogMalaysia.com

Oracle Services : Manually / Automatic

Okies , bagi korang yang cam aku .. ade database local Oracle , mesti nyampah gile ngan resource yg oracle makan... Tips nih, atas cadangan Puan Fiza , akan aku kongsikan bersama disini.

Pastu nak stop service , kene buat manual ... satu2 .. So sini aku post script yg aku buat , guna beberapa rujukan dari net , cadangan dari bro Sascha .... Segala kecederaan , kerosakan yang berlaku ... aa..korang pk a sendiri... Ade 2 , satu set StartMode jadik Manual (+Akan stopkan service mase korang execute) , dan StartMode jadik Auto (+Start balik service).. Macam yg aku cakap tadi , aku buat sendiri script nih berdasarkan rujukan dari net ... So, maybe x 100% jalan..Cara guna , bukak notepad , copy+paste script nih , save as NamaFail.vbs.. pastu double click fail vbs nih



StartMode = Manual
strComputer = "."
intKira = 0
intFail = 0

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

strService = "Oracle"

Set colListOfServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service WHERE Name LIKE '%" & strService & "%'")
For Each objService in colListOfServices

'Only act on service if not disabled
'Wscript.Echo objService.StartMode
If objService.StartMode = "Auto" Then

'Stop Service
returnCode = objService.Change( , , , , "Manual")
'objService.Change( , , , , "Manual")
returnCode = objService.StopService()
'Wscript.Echo objService.StartMode
'WScript.Sleep 5000

'Start Service
'returnCode = objService.StartService()

If returnCode <> 0 Then
'Test code below
'Wscript.Echo "Error " & returnCode
intFail = intFail +1
else
intKira = intKira +1
End If

End If

Next

if intKira > 0 then
msgbox "Berjaya Stop : " & intKira & vbcrlf & "Gagal : " & intFail
else
msgbox "Gagal"
end if




StartMode = Auto
strComputer = "."
intKira = 0
intFail = 0

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

strService = "Oracle"

Set colListOfServices = objWMIService.ExecQuery _
("SELECT * FROM Win32_Service WHERE Name LIKE '%" & strService & "%'")
For Each objService in colListOfServices

'Only act on service if not disabled
'Wscript.Echo objService.StartMode
If objService.StartMode = "Manual" Then

'Stop Service
returnCode = objService.Change( , , , , "Automatic")
'Wscript.Echo objService.StartMode
'WScript.Sleep 5000

'Start Service
returnCode = objService.StartService()

If returnCode <> 0 Then
'Test code below
'Wscript.Echo "Error " & returnCode
intFail = intFail +1
else
intKira = intKira +1
End If

End If

Next

if intKira > 0 then
msgbox "Berjaya Start : " & intKira & vbcrlf & "Gagal : " & intFail
else
msgbox "Gagal"
end if

2 ulasan:

ashiena berkata...

smart.. thanks

peah @ peps berkata...

..bagus..bagus...atas nasihat gua..lu buh gak...tak de pun credit utk guaa....