Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 13 of 13
  1. #1
    Join Date
    Jun 2004
    Posts
    113

    Using dos commands with buttons

    OK I know I can do this with a batch file but can i use the following dos command with a button?

    @netsh interface ip set address "Local Area Connection" static 192.168.1.2 255.255.255.0 192.168.1.1 1


    I really want to make three input boxes so I can set ip details, ie ip address, netmask and gateway - then press a button to change my network card details.

    Can I do this with apms or will I just need to use dos to do it? thanks.

  2. #2
    Join Date
    Jun 2002
    Location
    Israel
    Posts
    1,843

  3. #3
    Join Date
    Jun 2004
    Posts
    113
    I got it to work like this:

    ipconf.txt had the following info:
    @netsh interface ip set address "Local Area Connection" static aaa.aaa.aaa.aaa bbb.bbb.bbb.bbb ccc.ccc.ccc.ccc 1

    -----------------------------------------------------------------------

    result1 = Input.GetText("Input1");
    result2 = Input.GetText("Input2");
    result3 = Input.GetText("Input3");

    SourceFile = TextFile.ReadToString("AutoPlay\\Scripts\\ipconf.t xt")
    change1 = String.Replace(SourceFile, "aaa.aaa.aaa.aaa", result1, false);
    TextFile.WriteFromString("AutoPlay\\Scripts\\ipcon f.bat", change1, false)

    SourceFile = TextFile.ReadToString("AutoPlay\\Scripts\\ipconf.b at")
    change2 = String.Replace(SourceFile, "bbb.bbb.bbb.bbb", result2, false);
    TextFile.WriteFromString("AutoPlay\\Scripts\\ipcon f.bat", change2, false)

    SourceFile = TextFile.ReadToString("AutoPlay\\Scripts\\ipconf.b at")
    change3 = String.Replace(SourceFile, "ccc.ccc.ccc.ccc", result3, false);
    TextFile.WriteFromString("AutoPlay\\Scripts\\ipcon f.bat", change3, false)

    File.Run("AutoPlay\\Scripts\\ipconf.bat", "", "", SW_SHOWNORMAL, false);


    ----------------------------------------------------------------------

    Surely there must be a better way to do this without the need for changing strings in a txt file and having to write a batch file - can't I just use some command in apms to do this for me - those examples in the above post don't really let me know how to use the proper syntax and i can't get it to work properly using the command line option with a button because or the "Local Area Connection" part having the quotes in it.

  4. #4
    Join Date
    Jul 2003
    Posts
    712
    I'm just thinking out loud here ...

    Does command.com (cmd) allow you to pass a command to it as an argument?

    If so, you could use File.Run, and pass your command as the arguments string.

    Desmond.

  5. #5
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Quote Originally Posted by Desmond
    I'm just thinking out loud here ...

    Does command.com (cmd) allow you to pass a command to it as an argument?

    If so, you could use File.Run, and pass your command as the arguments string.

    Desmond.

    Yes it does. For instance if you click on Start->Run and type the following.

    cmd /c "ipconfig"

    or

    cmd /k "ipconfig"

    The command window will then launch and execute what is contained in the quotes. the slash is for keep open or close.

    HTH
    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  6. #6
    Join Date
    Jul 2003
    Posts
    712
    Hey, that's really neat! Super useful.

  7. #7
    Join Date
    Jun 2004
    Posts
    113
    Quote Originally Posted by Desmond
    I'm just thinking out loud here ...

    Does command.com (cmd) allow you to pass a command to it as an argument?

    If so, you could use File.Run, and pass your command as the arguments string.

    Desmond.
    Tried that and it doesn't work because of the "Local Area Connection" part is already in quotes, however if you could post an example of what you mean I am sure that other apms forum users would find this info usefull.

    I like apms and it can do alot of stuff - but surely it should be able to perfom basic tasks that dos can manage?

  8. #8
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Try one or both of these

    --Escape the quotes within the doublequotes
    cmd /k "@netsh interface ip set address \"Local Area Connection\" static aaa.aaa.aaa.aaa bbb.bbb.bbb.bbb ccc.ccc.ccc.ccc 1"

    --uses single quotes to enclose the doublequotes
    cmd /k '@netsh interface ip set address "Local Area Connection" static aaa.aaa.aaa.aaa bbb.bbb.bbb.bbb ccc.ccc.ccc.ccc 1'
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  9. #9
    Join Date
    Jun 2004
    Posts
    113
    Quote Originally Posted by TJ_Tigger
    Try one or both of these

    --Escape the quotes within the doublequotes
    cmd /k "@netsh interface ip set address \"Local Area Connection\" static aaa.aaa.aaa.aaa bbb.bbb.bbb.bbb ccc.ccc.ccc.ccc 1"

    --uses single quotes to enclose the doublequotes
    cmd /k '@netsh interface ip set address "Local Area Connection" static aaa.aaa.aaa.aaa bbb.bbb.bbb.bbb ccc.ccc.ccc.ccc 1'
    OK tried both of those but they don't work - any other ideas?

  10. #10
    Join Date
    Jul 2006
    Posts
    4
    Good

    Thanks yosik

  11. #11
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    This is how I do it.

    Hope it helps.....

    Code:
    lac = "\"Local Area Connection\""
    cmd_args = "@netsh interface ip set address " ..lac.. " 192.168.1.2 255.255.255.0 192.168.1.1 1"

  12. #12
    Join Date
    Aug 2004
    Location
    Somewhere in Texas, USA
    Posts
    417
    Sorry....left out some of the code.

    Here it is again.


    Code:
    lac = "\"Local Area Connection\""
    cmd_args = "@netsh interface ip set address " ..lac.. " 192.168.1.2 255.255.255.0 192.168.1.1 1"
    
    File.Run("CMD.exe", "/c \"\""..cmd_args.."", "", SW_SHOWNORMAL, true);

  13. #13
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Should be able to accomplish the same thing on one line like this


    File.Run("CMD.exe", "/c \"@netsh interface ip set address \"Local Area Connection\" 192.168.1.2 255.255.255.0 192.168.1.1 1\"", "", SW_SHOWNORMAL, true);

    or I would think this would work too

    File.Run("CMD.exe", '/c "@netsh interface ip set address "Local Area Connection" 192.168.1.2 255.255.255.0 192.168.1.1 1"', "", SW_SHOWNORMAL, true);

    The entire argument section is contained in single quotes to the doubles will be interpreted as literal double qoutes.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

Similar Threads

  1. i love buttons !
    By noonmoon in forum AutoPlay Media Studio 5.0
    Replies: 8
    Last Post: 01-15-2010, 05:05 AM
  2. Adding results of Dos commands to a file
    By G Mills in forum Setup Factory 7.0
    Replies: 9
    Last Post: 03-22-2006, 04:37 PM
  3. DOS commands
    By John_Klassek in forum AutoPlay Media Studio 5.0
    Replies: 4
    Last Post: 09-16-2004, 08:48 AM
  4. Replies: 8
    Last Post: 10-30-2003, 08:32 AM

Posting Permissions

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