CreateProcess() + Command Line

This is a discussion on CreateProcess() + Command Line within the Windows Programming forums, part of the Platform Specific Boards category; Code: cmd /C "net localgroup > C:\gList.txt \ " Try removing the last (Bold red) backslash and then run the ...

  1. #16
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Code:
    cmd /C "net localgroup > C:\gList.txt\"
    Try removing the last (Bold red) backslash and then run the command

  2. #17
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    sorry...copy&past failure :S

    Code:
    strcpy_s(buffer, sizeof(buffer), "cmd /C \"net localgroup > C:\\gList.txt\"");
    the cmd will read:
    cmd /C "net localgroup > C:\gList.txt"
    Why wont it work?
    "Artificial Intelligence usually beats natural stupidity."

  3. #18
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    Quote Originally Posted by IndioDoido View Post
    something really strange is happening...

    i'm having no problems using createProcess() to execute commands like:




    but then run this simple command:


    it doesn't work
    it creates a empty gList.txt file...

    i tried to run this command with system() and it doesn't work either

    why is that?
    First off I don't see how any of that is working because you are not representing backslashes correctly in any of those three cases.

    Okay well you ........ing edited after I posted. So in your last case you aren't representing the backslash correctly.
    Last edited by MeTh0Dz; 11-14-2008 at 10:52 AM. Reason: OP Edited

  4. #19
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Quote Originally Posted by MeTh0Dz View Post
    First off I don't see how any of that is working because you are not representing backslashes correctly in any of those three cases.

    Okay well you ........ing edited after I posted. So in your last case you aren't representing the backslash correctly.
    I wouldn't think his code would work due to the fact that the command line param in the CreateProcess function is modified internally by the function therefore string literals cause errors in all the implementations I've used. It's also documented by microsoft.

  5. #20
    Registered User IndioDoido's Avatar
    Join Date
    Apr 2007
    Posts
    194
    hi guys!

    i resolved the problem...

    it's all about authentication.
    i have to insert my windows admin authentication in the service properties of my server application so that it can run the app in admin mode.

    So i did it, and now i can run that command
    "Artificial Intelligence usually beats natural stupidity."

  6. #21
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    Regardless of anything else...


    cmd /C "net localgroup > C:\gList.txt"
    Is not right...

    '\\'

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

Similar Threads

  1. CreateProcess with arguments
    By Niara in forum Windows Programming
    Replies: 14
    Last Post: 09-08-2007, 06:41 AM
  2. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 01:07 AM
  3. question on CreateProcess() redirection
    By ac251404 in forum Windows Programming
    Replies: 13
    Last Post: 07-18-2006, 12:06 PM
  4. CreateProcess
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 05-12-2002, 07:45 AM
  5. CreateProcess()
    By Newfie in forum C++ Programming
    Replies: 2
    Last Post: 05-07-2002, 08:31 AM

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