ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide Command Shell window (https://www.excelbanter.com/excel-programming/377730-hide-command-shell-window.html)

Corey

Hide Command Shell window
 
Hi Folks,

I'm trying to use the following VBA code to verify a list of server's DNS
record. Although the results are correct, the command shell window always
appears. Is any way to completely hide it? TIA.

Corey

Code:

Function MyNslookupExe(ByRef fstrFQDN As String, ByRef fstrRealIP As String,
fstrCmd As String)

' The function is to receive nslookup result.

Dim WSH, wExec
Dim Result As String
Dim tmp

fstrFQDN = ""
fstrRealIP = ""

Set WSH = CreateObject("WScript.Shell")
Set wExec = WSH.Exec(fstrCmd)

Result = wExec.StdOut.ReadAll

tmp = Split(Result, vbCrLf)

If tmp(3) < "" And Left(tmp(3), 4) = strName Then

fstrFQDN = LCase(Trim(Right(tmp(3), Len(tmp(3)) - Len(strName) - 1)))
fstrRealIP = LCase(Trim(Right(tmp(4), Len(tmp(4)) - Len(strAddress)
- 1)))

End If

Set wExec = Nothing
Set WSH = Nothing

End Function



All times are GMT +1. The time now is 01:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com