Communication with cmd.exe

This is a discussion on Communication with cmd.exe within the C++ Programming forums, part of the General Programming Boards category; Hi, how can i communicate with cmd.exe? I use console application on WinXP. I want to do like this: cin ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    188

    Exclamation Communication with cmd.exe

    Hi, how can i communicate with cmd.exe? I use console application on WinXP.
    I want to do like this:

    cin >> user_input;
    writetocmd << "Net user" << user_input << " *";
    cin >> pass_input;
    writetocmd << pass_input;
    writetocmd << pass_input;

    Is this possible? How?

    Greetings,
    Fredrik!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,803
    cout?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,754
    sounds like system()
    To be or not to be == true

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Maybe, i don't know. I'm a noob at C++. Learning by making a change password by username function.
    Can someone check how you do this? Would be grateful!

  5. #5
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,754
    build string like
    std::string temp = "net user Livijn new_password /add"

    using input from the user
    and run system(temp.c_str()) on this string
    To be or not to be == true

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    In cmd you first enter "Net user Freedrik *" and then password "test" and thjen confirm pass "test" so this doesnt work. Here is my code:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        string temp = "Net user Freedrik * test /add";
        system(temp.c_str());
    }

  7. #7
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Damn it!!! I tested a thing and it worked...
    Now i don't know my password to my account anymore. I wrote:
    Code:
    int main()
    {
        string temp = "Net user Freedrik * /add";
        system(temp.c_str());
    
        string temp2 = "test /add";
        system(temp2.c_str());
    
        string temp3 = "test /add";
        system(temp3.c_str());
    }
    So whats my god damn password? :S It's not test or test/add
    Last edited by Livijn; 03-29-2007 at 08:44 AM.

  8. #8
    "I Win!" by U. Lose vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,754
    probably *
    To be or not to be == true

  9. #9
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    No, it's not "*" either. What can it be?
    Can i change my password or something instead?

  10. #10
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    I've tested many things but none of them works. I'm so confused.

    And it popped up a window also when i clicked compile and drive(right word?). It was a program that i've done. Jinky, why did it showed up?

  11. #11
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    Can i use any cd that change the password? If i don't can open that login again i'll commit suicide. I promise!

  12. #12
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Type in "net help user" and read up on what you did.

    When you put *, it should have prompted you for the password. Whatever you typed is the password at that point, possibly a blank password.

    Code:
    *            Produces a prompt for the password. The password is not
                 displayed when you type it at a password prompt.
    Hope you didn't pound random keys.

  13. #13
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    net user user_name new_password

    The program you wrote should pop up a new command prompt where you have to type the user's password (the last two system lines will most likely give you an error that "test" isn't a recognized command)
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  14. #14
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    This is what got me into programming!! Spamming people.

    Code:
    #include <string>
    #include <iostream>
    
    // what's system in, dwks? cstdlib?
    
    int main( void )
    {
    	std::string name, comment;
    
    	std::cout<< "Enter name: ";
    	std::cin >> name;
    
    	std::cout<< "Enter comment: ";
    	std::getline( std::cin, comment );
    
    	system( ( "net send " + name + " " + comment ).c_str() );
    
    	return 0;
    }
    Note to self: Read thread before posting next time.

  15. #15
    Registered User
    Join Date
    Jan 2007
    Posts
    188
    I did not pund in any key. Only clicked down the cmd.exe men i drove the program. Is there any program where you can see your password or anythink alike??

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unkown Hang
    By Bladactania in forum C Programming
    Replies: 31
    Last Post: 04-22-2009, 09:33 AM
  2. Encapsulating cmd.exe
    By bennyandthejets in forum Windows Programming
    Replies: 4
    Last Post: 05-17-2005, 12:46 AM
  3. Looking for communication lib
    By BrownB in forum C Programming
    Replies: 3
    Last Post: 04-27-2005, 10:01 AM
  4. Serial communication packets
    By Roaring_Tiger in forum C Programming
    Replies: 3
    Last Post: 04-26-2003, 08:33 AM
  5. communication
    By in need of help in forum C Programming
    Replies: 3
    Last Post: 12-27-2002, 02:56 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21