Thread: text files and autorun?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    21

    text files and autorun?

    hi
    i am tring to get a autorun to open a *.*txt file

    for example
    [autorun]
    open=text.txt
    icon=star.ico

    however it says invalid 32 app

    do you know how i open a text file? do i have to use a shell?

    thanks for your help

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hmm, i may well be wrong but i think autorun can only be used to run an application.

    I would advise if you are sure you wanna run a txt file, just write a small exe to run the text file then close itself.

    However there phraphs is a way to do it from an autorun file, but it would be pretty easy to make a small app to do it then just launch that from your cd.

    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    21
    thanks

    thats what i did but i used a small 3rd party app to do it

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    3
    this is what you want

    [autorun]
    open=start text.txt
    icon=star.ico

    you must add the start to start non-executable programs...

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Originally posted by dazed66
    this is what you want

    [autorun]
    open=start text.txt
    icon=star.ico

    you must add the start to start non-executable programs...
    Start is ok for starting documents....but the downside is that it loads a console window for a few seconds.......To do this without the window you could make your own file opener like so....

    Code:
    #include <windows.h>
    
    int WINAPI WinMain(HINSTANCE hThisInstance,
    HINSTANCE hPrevInstance, LPSTR lpszArgument,
    int nFunsterStil)
    {
        CHAR szDir[MAX_PATH +1]; //Name of directory
    
        GetCurrentDirectory(MAX_PATH +1,szDir);//Where is this prog run?
    
        if((int)ShellExecute(HWND_DESKTOP,"open",
        lpszArgument,NULL,szDir,SW_SHOWNORMAL)<= 32){
            MessageBox(HWND_DESKTOP,"Could not open file",//Error
            "Error",MB_ICONEXCLAMATION | MB_OK);
        }
        return 0;
    }
    Compile this as StartW.exe and add it on the CD with the text.txt. Now change the

    >>open=start text.txt

    to

    >>open=startw text.txt

    and it should open without the annoying console window....

    Another way I guess is to use

    >>open=C:\windows\notepad.exe text.txt

    This will open the notepad app with the document you specify...the big downside is that you dont know that notepad is where you specified (it is differet on NT, Win2k...) and also you dont know that the user likes to use notepad...they may like another text editor such as textpad (the program I did above will ask the system to open the file...therefore it will know the prefered text editor)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. autorun.inf files
    By ober in forum Tech Board
    Replies: 3
    Last Post: 04-02-2003, 07:44 AM