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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax problem, could someone please help. 1

Status
Not open for further replies.

Modex

Programmer
Sep 15, 2002
155
GB
Hi All,

I'm fairly new to this VB scripting and am having a problem with this little piece of code.

Basically I want to run IPCONFIG /ALL to a file and then read the file.

It runs IP config, but wont output to a file.

Any help would be really appreciated

ModeX

SCRIPT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Dim fso, sh, r, s, pe
Set sh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

'--run a program: -------------------

sh.run "C:\windows\system32\ipconfig.exe /all > c:\ipconfig.txt"
sh.Run "C:\windows\notepad.exe c:\ipconfig.txt", 1, false

END OF SCRIPT >>>>>>>>>>>>>>>>>>>>>>>>
 
Hello Modex,

You need to spawn a %comspec% session to effect the .run and redirection. Then, you need to wait for the file being generated is completed and available.
[tt]
sh.run "%comspec% /c C:\windows\system32\ipconfig.exe /all > c:\ipconfig.txt"
wscript.sleep 2000 'an informal treatment
sh.Run "C:\windows\notepad.exe c:\ipconfig.txt", 1, false
[/tt]
But, here for a formal treatement, you have to use fso to get the file for appending say see if error occur. If no error, it means the file is available.

regards - tsuji
 
Hi Tsuji

Thanks very much for that, very much appreciated

Cheers

ModeX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top