Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with echoing com aoutput to txt file

Status
Not open for further replies.

spyrospappas

Programmer
Dec 14, 2006
4
0
0
GR

So I have this problem.

I use "%comspec% /C net view >c:\temp.txt" via "WScript.CreateObject("WScript.Shell")" command.

I run the command. The file is created but nothing is in.
No errors.
If i use "ipconfig or dir etc" at the place of "net view" everything works fine.
Looks like "net" commands run but cant be echoed to a file.
When i run the command directly from the command line everything works fine.(File is created, data in file)
What is the problem?
I think that file is created with out waiting for "net view" command to end.
what should i do?

 
how weird. I just tried the following without a problem.

Dim objShell

Set objShell = CreateObject("WScript.Shell")

objShell.Run "%comspec% /c net view >> c:\test.txt", 0, True

dm4ever
--------------------------------------------------------------------------------
My approach to things: K.I.S.S - Keep It Simple Stupid
 
It doesnt work for me.


I dont know why? If i use netstat works fine.


WHY?
 
the correct syntax is:

objShell.Run "cmd.exe /c net view > c:\test.txt"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top