We are using a button in MS Access to run the VBA code below to run "NSLOOKUP" against many IP addresses in the command shell and print what is returned to a text file. The only problem is that when nothing is returned, we can't capture that. We need to know when nothing (or an error message) is returned by NSLOOKUP. When we run NSLOOKUP manually, we do get an error message on screen, but it is not captured by the code below.
If you can easily modify our existing code to fix this, that would be best as I'm a novice.
Private Sub Command0_Click()
Dim ff As Integer
Dim x As Integer
Dim outputfile As String
outputfile = "c:\IPOutput.txt"
ff = FreeFile
Open "c:\IPHostname.txt" For Input As #ff
Do Until EOF(ff)
Line Input #ff, Ln
PID = Shell(Environ$("COMSPEC") & " /c nslookup " & Ln & " >> " & outputfile)
If PID = 0 Then
MsgBox "Shell command didn't work", vbOKOnly
hProcess = OpenProcess(&H100000, True, PID)
WaitForSingleObject hProcess, -1