We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Sub SMTP_STATUS ' this is a subroutine, but could be a function that returns the SMPT status Dim strCommand Dim intSMPTStatus Dim intDosError ' the DOS command will be to query the SMTPSVC status ' I could not figure out how to get the strCommand = "CMD /C SC QUERY SMTPSVC" intStyle = 10 intDOSError = 0 intSMTPStatus = 0 Dim fldTemp, strTempName set fsoRun = CreateObject("Scripting.FileSystemObject") Set fldTemp = fsoRun.GetSpecialFolder(TEMP_FOLDER) strTempName = fldTemp.Path & "\" & fsoRun.GetTempName Dim WshShell Set WshShell = CreateObject("Wscript.Shell") Return = WshShell.Run(strCommand & " >" & strTempName, intStyle, True ) 'Get the output from the command Dim filOutput Set filOutput = fsoRun.OpenTextFile(strTempName, FOR_READING) While Not filOutput.AtEndOfStream strOutput = filOutput.ReadLine objEntry.WriteLine (strOutput) ' This is where I would like to get the SMTP status If InStr(strOutput,"STATE") > 0 And InStr(strOutput,"RUNNING") > 0 Then ' If the status of SMPTSVC is running then flag it as 1 intSMPTStatus = 1 End If Wend filOutput.Close intDOSError = Return 'Delete the temporary file fsoRun.DeleteFile strTempName Set WshShell = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.