[OTHER] HOWTO: get autorun.inf to execute multiple programs.

Discussion in 'Windows Operating Systems' started by ShadowGeoff, Feb 17, 2009.

  1. ShadowGeoff

    ShadowGeoff Member

    Joined:
    May 25, 2006
    Messages:
    2,111
    Location:
    Perth
    I have a third party app which is a bit flawed that I am distributing to users (on a dvd) who want things to 'just work'.

    The only solution I could come up with to stop them calling me was to put a readme on the DVD and make it force run when the disk is inserted with autorun.inf.

    However autorun.inf also had to start the main .exe application on the DVD and usually you cannot get autorun to do two things.

    This seems to be a common problem that people have so I thaught I would post my way of getting around it and perhaps someone could suggest an improvement.

    1. You must put notepad.exe on the disk.
    2. Make autorun.inf open autorun.bat instead of the exe.
    2. Make an autorun.bat to do the following,

    Echo Off
    @START notepad.exe readme.txt
    @ping (some ip you know is unreachable)
    @START yourapp.exe
    EXIT


    Suggested Improvements:
    1. Make the .bat use notepad off the user's machine.
    2. I got that Echo and @ stuff somewhere to try to supress the cmd window but it did not work.
    3. The ping step is a just like a pause or sleep command, but I don't know a good one to use.
     
    Last edited by a moderator: Feb 25, 2009
  2. GooSE

    GooSE New Member

    Joined:
    Jun 26, 2001
    Messages:
    6,679
    Location:
    Sydney
    Everyone's system32 folder will be set in their PATH environment variable, so simple executing 'notepad.exe file.txt' is fine
     
  3. Rezin

    Rezin Member

    Joined:
    Oct 27, 2002
    Messages:
    9,490
    You should just be able to run notepad.exe, seeing as it's in System32, which is in the path system variable.

    Could look into this.

    Code:
    Dim objShell
    Set objShell = WScript.CreateObject("Wscript.Shell")
    
    objShell.Run "cmd /c ping 127.0.0.1", 0, False
    Use 127.0.0.1... but if there's no NIC, I don't think it'll do what you want.

    Check out this though.

    Edit: Pointed that link to another page.
     
    Last edited: Feb 17, 2009
  4. OP
    OP
    ShadowGeoff

    ShadowGeoff Member

    Joined:
    May 25, 2006
    Messages:
    2,111
    Location:
    Perth
    so notepad will work and we (mabye) can use,

    Wscript.Sleep 1000

    to pause for 1 second.

    Does anyone know the proper way to supress the display of the command window?.
     
  5. Rezin

    Rezin Member

    Joined:
    Oct 27, 2002
    Messages:
    9,490
    You can do it all in a WSH script, and call that from the autorun.inf (you may have to call it with cscript.exe).

    Run Method (Windows Script Host)

    Code:
    Dim objShell
    Set objShell = WScript.CreateObject("WScript.Shell")
    
    objShell.Run "cmd /c notepad.exe PathTo\document.txt", 0, False
    
    WScript.Sleep 1000
    
    objShell.Run "cmd /c PathTo\yourapp.exe", 0, False
    What Windows version(s) are you going to use this on?

    You can also use /MIN with Start to minimise the window... it'll still show in the taskbar though.
     
    Last edited: Feb 17, 2009
  6. OP
    OP
    ShadowGeoff

    ShadowGeoff Member

    Joined:
    May 25, 2006
    Messages:
    2,111
    Location:
    Perth
    Is it a problem with this that you need to describe the path to the files on the disk where different people may use different drive letters?
     
  7. DavidRa

    DavidRa Member

    Joined:
    Jun 8, 2002
    Messages:
    3,073
    Location:
    NSW Central Coast
    Some notes:

    • You can do it all in Windows Script (VBS or JS, your call)
    • You don't have to use CMD /C NOTEPAD, just NotePad is fine
    • WSCRIPT.EXE is the "hidden Windows" version of CSCRIPT.EXE, so use that and there's no black window
    • 99% of boxes will have Windows Script 5.6 which is the version you want
    • AutoRun.inf should execute something like "WSCRIPT //NOLOGO //B Auto.VBS"
    • Place all your Auto bits in a subfolder to avoid clutter in the disk root (apart from autorun.inf obviously)
    • Consider your approach if the user has had someone disable autorun (Conficker et al)
     
  8. revhed

    revhed Member

    Joined:
    Aug 22, 2001
    Messages:
    1,526
    Location:
    Darwin
    Or you could use good old DOS. It has a PAUSE command, you can echo each line of your readme into a command window and then launch your app after that.

    If you're hell bent on useing VBscript then you could code it to wait for user input (eg, press the Enter key) or just use the VBscript for a message box (which has a "OK" button on it anyway)

    There are other more powerful tools to re-package your application too, such as WISE Package Studio......
     

Share This Page

Advertisement: