Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

This question is for aikimark only, thanks!

aikimark,

I tired Shell("tracert " & strmachinename & " > " & App.Path & "\paths.lst"), it didn't work.

Dim MachineName As String
Dim ReturnCode As Integer
MachineName = "gluon"
ReturnCode = Shell("tracert " & MachineName & " > " & "c:\vbwork\traceroute\tracert.txt")

It did not write anything to the file.  "gluon" is a working machine, I could tracert it under DOS.

Thanks,
hxia


0
hxia
Asked:
hxia
  • 3
  • 2
1 Solution
 
rspahitzCommented:
I saw your previous message on this, so I'll help out.

On Windows, certain "DOS" commands require a prefix command to "jumpstart them.  The two choices are "start" and "cmd".  Try something like this:

ReturnCode = Shell("cmd /c tracert " & MachineName & " > " & "c:\vbwork\traceroute\tracert.txt")

For Win95/98/ME systems, replace cmd with command.  FYI, the /c will close the DOS window when the command completes.  Also, this may not work on XP without a special plug-in (or so I've heard.)
0
 
hxiaAuthor Commented:
Hi rspahitz,

Thanks!  Actually, I was able to tracert just using that coding, but could not write to the file.  If i just do this, Shell("tracert " & MachineName), it'll work, and I can see the output on the console.

I tried with cmd, still couldn't write to a file.

hxia
0
 
rspahitzCommented:
I had problems with the original, but on my Win2000 machine, this worked (althogh delayed because the trace took a while):

  Shell ("cmd /c tracert www.microsoft.com > " & "c:\tracert.txt")

Make sure that you have a valid result path.
Also make sure that you wait until the DOS window (launched by Shell) completes before looking for the file.
0
 
hxiaAuthor Commented:
Yep, it worked.  Thanks!
0
 
rspahitzCommented:
Glad to help.  I hope aikmark won't get upset ;)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

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!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now