Results 1 to 4 of 4

Thread: [RESOLVED] Shelling out ipconfig on win2000

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    59

    Resolved [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

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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...
    Last edited by Siddharth Rout; Oct 19th, 2010 at 06:50 AM. Reason: Typo
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2009
    Posts
    59

    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.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Shelling out ipconfig on win2000

    Quote Originally Posted by pr1ngl3 View Post
    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
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width