[RESOLVED] Shelling out ipconfig on win2000
Hi,
I was wondering if someone can help me or have had a similar experience.
I am trying to shell ipconfig with an output to a text file which I can later parse.
Code:
ShellandWait ("ipconfig >" & sIPFileLoc)
sIPFileLoc is a string variable for the file location and name.
ShellandWait is a function to wait until the shell has completed(found on this very site)
Now when I run this command, it complains of an invalid syntax because of the ">" yet if I manually run the same command from a command prompt it works fine.
There is no problem with directory naming as sIPFileLoc is stripped to 8.3 file naming standards (e.g. Documents and Settings becomes Docume~1) even so, I have tried it with Chr(34) wrapped around the variable but still the same.
So I created a batch file just to see if it would work.. When running the batch file with @echo on, it outputs an additional 1 as such
command in bachfile:
Code:
ipconfig >c:\testdir\ip.txt
Output:
Code:
ipconfig 1>c:\testdir\ip.txt
But this DOES work and creates ip.txt containing the output of ipconfig.
So I altered the Shell command to incorporate the 1 (just to see)
Code:
ShellandWait ("ipconfig 1>" & sIPFileLoc)
But that did not work.
Now I can create a batch file on the fly, shell it then delete it once complete, but that is rather messy and was wondering if there was a work around.
PS, I can not use WinSock control to get the IP address as it is a standalone app.
Thanks
Re: Shelling out ipconfig on win2000
Whoa!
No... To use Ipconfig with ShellandWait you have to use it this way :)
Code:
Ret = ShellAndWait("Command.com /c ipconfig > " & sIPFileLoc)
Where sIPFileLoc is a valid path...
Re: Shelling out ipconfig on win2000
Cheers Koolsid,
command.com /c !!!!!
aaaargh! an oversite on my behalf, should have seen that. Don't use shell much and thinking about it now, it's obvious.
So you are aware, the ommited space (Chr(32)) between > and " was due to me messing with the batch file, which complained when it was there.
Thanks for your help.
Re: Shelling out ipconfig on win2000
Quote:
Originally Posted by
pr1ngl3
Cheers Koolsid,
command.com /c !!!!!
aaaargh! an oversite on my behalf, should have seen that. Don't use shell much and thinking about it now, it's obvious.
So you are aware, the ommited space (Chr(32)) between > and " was due to me messing with the batch file, which complained when it was there.
Thanks for your help.
Glad to be of help :)