Results 1 to 13 of 13

Thread: Excute a Dos FIle

  1. #1

    Thread Starter
    Lively Member moja's Avatar
    Join Date
    May 2002
    Posts
    74

    Excute a Dos FIle

    I have a Win32 project and i want to execute an exe or BAT file from wihin the project

    and I wnat the code for changing the directory from the c: to d: etc.

    thanks

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Q1 : You can use ShellExecute
    Code:
    ShellExecute(0,"OPEN","C:\\test.bat","","",SW_NORMAL);
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Lively Member moja's Avatar
    Join Date
    May 2002
    Posts
    74
    this didn't work
    I a using VC++ 6 and
    my Project is WIn32 console Aplication Project (Dos type)
    Code:
    #include "stdafx.h"
    main()
    {
    	int x;
    	printf("\n");
    printf("Please Make your choice\n");
    printf("--------------------------\n");
    printf("1- Run close-up 6.5\n\n");
    printf("Or press Enter to Exit\n");
    
    		scanf("%d",&x);
    if (x==1)
    ShellExecute(0,"OPEN","d:\cls\crm","","",SW_NORMAL);
    	return 0;
    
    }

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    You must include <windows.h>
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Oh, its a console program. I just assumed you meant a windows app. Just add #include <windows.h> at the top.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6

    Thread Starter
    Lively Member moja's Avatar
    Join Date
    May 2002
    Posts
    74
    Still no Help

    I don't wan to run this Applicaion from Windows
    I want to make it run from dos .
    I want to make it run from Autoexec.bat

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I may be wrong, but I think you have to be in windows to use the windows resources. Unless it's packed in there during compilation. Not sure, though.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8

    Thread Starter
    Lively Member moja's Avatar
    Join Date
    May 2002
    Posts
    74
    my Project is WIn32 console Aplication Project (Dos type)

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by moja
    my Project is WIn32 console Aplication Project (Dos type)
    I think we've already established that...
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10

    Thread Starter
    Lively Member moja's Avatar
    Join Date
    May 2002
    Posts
    74
    my friend
    1- I tried to use include <windows.h> with no Help
    2- I want o run my application just prior to windows staring (i.e. include it in Autoexec.bat )

    so no requiremnt for windows resorces to be there.


    am I right.

  11. #11
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    If it's supposed to be outside of Windows... and you're trying to use Windows.h... does that make any sense? Anyway, it looks like you're trying to create a bootloader of sorts. Autoexec.bat is called after the default bootloader, I just thought I'd let you know. And, all that you are trying to do is easily accomplished WITH a batch file. I suggest you learn them inside out... man, it was fun tweaking BAT files back in the day...
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  12. #12
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by moja
    my friend
    1- I tried to use include <windows.h> with no Help
    2- I want o run my application just prior to windows staring (i.e. include it in Autoexec.bat )

    so no requiremnt for windows resorces to be there.


    am I right.
    I think the big thing you need to realize here is something you said yourself:

    my Project is Win32 console Aplication Project (Dos type)
    It is a Win32 Console Application. Not a DOS program.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  13. #13
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    Code:
    #include <stdlib.h>
    system("c:\\myfile.bat");

Posting Permissions

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



Click Here to Expand Forum to Full Width