/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
Underscore i computernavn.
Fra : Poul-Erik Juhl


Dato : 16-04-02 17:04

Jeg har forfattet spørgsmålet på engelsk, da jeg også har bruger
engelsktalende nyhedsgrupper.
I would like to use ADSI to stop and start services on a NT 4.0 server
running Exchange Server 5.5.
Our Intranet is running on a W2K server. This works fine as long the
computername has no underscore
in the name like "INTRANET", but if the name is "NT_SERVER_02" as it is for
me then it fails.
In an ASP page i have made the following code:
<body>
<%
virusattach()
Function virusattach()
Dim Computer
Dim ComputerName
Dim ComputerDomain
Dim TargetService
TargetService = "Alerter"
ComputerDomain = "NT_DOMAIN"
ComputerName = "INTRANET"
Set Computer = GetObject("WinNT://" & ComputerDomain & "/" & ComputerName &
",computer")
Set Service = Computer.GetObject("service", TargetService)
If Service.Status = 1 Then
Service.Start
Response.Write "The service " & Service.Name & " is started."
Else
If Service.Status = 4 Then
Response.Write "The service " & Service.Name & " is allready
started."
Else
Response.Write "The service " & Service.Name & " could not be
started."
End If
End If
End Function
%>
</body>

I have allso tryed compiling a DLL and regsvr32 it and using it on the IIS
server. The Visual Bascic
project and the DLL has the following data:
Project name and DLL name: NTServiceAdmin
Class Modul name: NTServiceManagement
Code:
Public Function ServiceOperations(ByVal TargetDomain As String, ByVal
TargetComputer As String, ByVal TargetService As String, ByVal
ServiceOperation As String) As Integer
Dim Computer As IADsComputer
Dim Service As IADsServiceOperations
Set Computer = GetObject("WinNT://" & TargetDomain & "/" &
TargetComputer & ",computer")
Set Service = Computer.GetObject("service", TargetService)
Select Case UCase(ServiceOperation)
Case "START"
If Service.Status = 1 Then
Service.Start
Else
If Service.Status = 4 Then
Err.Number = 1 'statusquo
Else
Err.Number = 2 'no change
End If
End If
Case "STOP"
If Service.Status = 4 Then
Service.Stop
Else
If Service.Status = 1 Then
Err.Number = 1 statusquo
Else
Err.Number = 2 'no change
End If
End If
Case "CONTINUE"
If Service.Status = 7 Then
Service.Continue
Else
If Service.Status = 1 Then
Err.Number = 1 statusquo
Else
Err.Number = 2 'no change
End If
End If
Case "PAUSE"
If Service.Status = 4 Then
Service.Pause
Else
If Service.Status = 1 Then
Err.Number = 1 statusquo
Else
Err.Number = 2 'no change
End If
End If
End Select
ServiceOperations = Err.Number
End Function

And then I call the DLL using the following in an ASP page:
<body>
<%
virusangreb()
Function virusangreb()
Dim ComputerName
Dim ComputerDomain
Dim Service
Dim TargetService
Dim StartStop
Dim ServiceManagement
StartStop = "start"
TargetService = "Alerter"
ComputerDomain = conDomain
ComputerName = "nt_server_02"

Set ServiceManagement =
Server.CreateObject("NTServiceAdmin.NTServiceManagement")
Resultat = ServiceManagement.ServiceOperations(ComputerDomain,
ComputerName, TargetService, StartStop)

If Resultat = 0 Then
Response.Write "The servicen " & TargetService & " is started."
Else
If Resultat = 1 Then
Response.Write "The servicen " & TargetService & " is already
started."
Else
Response.Write "The servicen " & TargetService & " could not be
started."
End If
End If
End Function
%>
</body>



 
 
Jakob Andersen (16-04-2002)
Kommentar
Fra : Jakob Andersen


Dato : 16-04-02 16:38

"Poul-Erik Juhl" <pe@pejuhl.dk> wrote in message
news:a9hejl$24i$1@sunsite.dk...
> in the name like "INTRANET", but if the name is "NT_SERVER_02" as it is
for

Tør man spørger hvorfor i har valgt at navngi med ulovlige(non-standard)
karakterer. Under migrering fra NT4 til w2k plejer underscores at blive
byttet ud med "-" istedet.

<http://support.microsoft.com/default.aspx?scid=kb;en-us;Q290816>

--
Jakob Andersen



Poul-Erik Juhl (16-04-2002)
Kommentar
Fra : Poul-Erik Juhl


Dato : 16-04-02 18:56

Exchange serveren køre på en NT 4.0 server; men IIS køre på W2K, og hvorfor
der i tidenes morgen er valg underscore i servernavnet ved jeg ikke, det er
en arv jeg har!

"Jakob Andersen" <jakob@effectus.dk> skrev i en meddelelse
news:a9hge2$aaq$1@news.cybercity.dk...
> "Poul-Erik Juhl" <pe@pejuhl.dk> wrote in message
> news:a9hejl$24i$1@sunsite.dk...
> > in the name like "INTRANET", but if the name is "NT_SERVER_02" as it is
> for
>
> Tør man spørger hvorfor i har valgt at navngi med ulovlige(non-standard)
> karakterer. Under migrering fra NT4 til w2k plejer underscores at blive
> byttet ud med "-" istedet.
>
> <http://support.microsoft.com/default.aspx?scid=kb;en-us;Q290816>
>
> --
> Jakob Andersen
>
>



Søg
Reklame
Statistik
Spørgsmål : 177554
Tips : 31968
Nyheder : 719565
Indlæg : 6408852
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste