Thread: System();

  1. #1
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Angry System();

    I am running my DOS application under Windows XP. I am using the following line of code to open ATXT.TXT with NOTEPAD.EXE. START is an internal command in DOS XP (thanx to an 'Unregistered' for that info!), but when I try to use the code it reports 'Bad command or file name', as if it's trying to find an executable. My line of code is this:-

    Code:
    system("START C:\WINDOWS\NOTEPAD.EXE C:\ATXT.TXT");
    I have typed this manually at the command processor and it produces the desired effect, but not with SYSTEM();. Any ideas?
    Kree'ta Tau'ri! Chaapa'ai!

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Your compiler didn't generat any warnings?

    Use \\ instead of \

  3. #3
    Unregistered
    Guest
    maybe you don't need "START"

  4. #4
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Unregistered
    maybe you don't need "START"
    whether or not it's needed, it should work if start is invoked.

    of course in this case the \ vs \\ is the problem
    hello, internet!

  5. #5
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    \\ or \

    I've tried using SYSTEM(); with both \ and \\ and both give the Bad command of file name error - I was wondering maybe if SYSTEM(); isn't compatible with XP?
    Kree'ta Tau'ri! Chaapa'ai!

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > wondering maybe if SYSTEM(); isn't compatible with XP?
    No, your compiler isn't. It's likely that at some point you'll find something which breaks the compatibility.

    My guess is, being a DOS compiler, it's looking for command.com, and
    - XP doesn't have command.com
    - command.com is not where your compiler expected to find it
    - your compiler can't find command.com because the PATH contains long filenames with spaces.
    - "START" is an embedded command of cmd.exe, not a separate executable (this is the thing that cannot be found)

    How about
    system("cmd.exe /c START C:\\WINDOWS\\NOTEPAD.EXE C:\\ATXT.TXT");

    Or save one level of crud by
    system("C:\\WINDOWS\\NOTEPAD.EXE C:\\ATXT.TXT");

  7. #7
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Talking Thanks Salem!

    Code:
    system("cmd.exe /c START C:\\WINDOWS\\NOTEPAD.EXE C:\\ATXT.TXT");
    It works!! Thanks everyone!
    Kree'ta Tau'ri! Chaapa'ai!

  8. #8
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946

    Re: Thanks Salem!

    Originally posted by Unimatrix139
    Code:
    system("cmd.exe /c START C:\\WINDOWS\\NOTEPAD.EXE C:\\ATXT.TXT");
    It works!! Thanks everyone!
    but now you have created a dos application that will only run on windows 2k and xp.
    hello, internet!

  9. #9
    Registered User Unimatrix139's Avatar
    Join Date
    Jun 2002
    Posts
    55

    Dos on XP

    Yeah, but it's just compatibility code; if my app detects XP it'll use this code otherwise it won't just trying to please everyone who could use my app!
    Kree'ta Tau'ri! Chaapa'ai!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 01:04 PM
  2. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 07:56 PM
  3. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  4. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 07:12 AM
  5. Number system base M, print numbers N digits wide...
    By biterman in forum C Programming
    Replies: 12
    Last Post: 11-19-2001, 04:31 AM