G
GLT
Hi I am trying to loop through a recordset and issue a dos command to start a
service. When I try to execute the code below, I get about 50 DOS windows
opening at the same time, can anyone advise if I can execute these commands
silently, and how can I capture the results? All help is greatly
appreciated...
Private Sub btnStartServices_Click()
Dim rs As DAO.Recordset
Dim strServer, strService, strCommand As String
Dim strQry As String
strQry = "qry01_StartServices"
Set rs = CurrentDb.OpenRecordset(strQry, dbOpenDynaset)
If rs.RecordCount = 0 Then MsgBox "No Records"
With rs
.MoveFirst
Do
Set strServer = rs![Server]
Set strService = rs![Service]
Me![nowStarting] = strServer & " - " & strService
Me.Refresh
Set objShell = CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("sc //" & strServer & " start " &
strService)
MsgBox objExecObject.StdOut.ReadAll()
' strCommand = "sc //" & strServer & " start " & strService
' Shell strCommand
.MoveNext
Loop Until .EOF
.Close
End With
Set rst = Nothing
End Sub
service. When I try to execute the code below, I get about 50 DOS windows
opening at the same time, can anyone advise if I can execute these commands
silently, and how can I capture the results? All help is greatly
appreciated...
Private Sub btnStartServices_Click()
Dim rs As DAO.Recordset
Dim strServer, strService, strCommand As String
Dim strQry As String
strQry = "qry01_StartServices"
Set rs = CurrentDb.OpenRecordset(strQry, dbOpenDynaset)
If rs.RecordCount = 0 Then MsgBox "No Records"
With rs
.MoveFirst
Do
Set strServer = rs![Server]
Set strService = rs![Service]
Me![nowStarting] = strServer & " - " & strService
Me.Refresh
Set objShell = CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec("sc //" & strServer & " start " &
strService)
MsgBox objExecObject.StdOut.ReadAll()
' strCommand = "sc //" & strServer & " start " & strService
' Shell strCommand
.MoveNext
Loop Until .EOF
.Close
End With
Set rst = Nothing
End Sub