Results 1 to 9 of 9

Thread: Autorun on a setup CD

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Sydney Australia
    Posts
    476
    Hi team
    Does anyone know about the autorun.inf?
    I want to check if an app (Flash) is installed and if it isn't to prompt for installation. I will have Flash setup on the CD. How do i do this?

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Wouldn't it be best to do this in your setup prgram not in the autorun?

  3. #3
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188

    Something like this:

    Put it all in a form!
    Change the form click event to form load.
    Change the r = startdoc document.txt to the exe that runs flash!

    Good Luck


    Option Explicit

    Private Declare Function ShellExecute Lib "shell32.dll" Alias _
    "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
    String, ByVal lpszFile As String, ByVal lpszParams As String, _
    ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

    Private Declare Function GetDesktopWindow Lib "user32" () As Long

    Const SW_SHOWNORMAL = 1
    Const SW_HIDE = 0

    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&

    Function StartDoc(DocName As String) As Long
    Dim Scr_hDC As Long
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
    "", "C:\", SW_HIDE)
    End Function

    Private Sub Form_Click()
    Dim r As Long, msg As String
    r = StartDoc("C:\document.txt")

    If r <= 32 Then
    'There was an error
    Select Case r
    Case SE_ERR_FNF
    msg = "File not found"
    Case SE_ERR_PNF
    msg = "Path not found"
    Case SE_ERR_ACCESSDENIED
    msg = "Access denied"
    Case SE_ERR_OOM
    msg = "Out of memory"
    Case SE_ERR_DLLNOTFOUND
    msg = "DLL not found"
    Case SE_ERR_SHARE
    msg = "A sharing violation occurred"
    Case SE_ERR_ASSOCINCOMPLETE
    msg = "Incomplete or invalid file association"
    Case SE_ERR_DDETIMEOUT
    msg = "DDE Time out"
    Case SE_ERR_DDEFAIL
    msg = "DDE transaction failed"
    Case SE_ERR_DDEBUSY
    msg = "DDE busy"
    Case SE_ERR_NOASSOC
    msg = "No association for file extension"
    Case ERROR_BAD_FORMAT
    msg = "Invalid EXE file or error in EXE image"
    Case Else
    msg = "Unknown error"
    End Select
    MsgBox msg
    End If
    If r > "32" Then
    MsgBox "File Found Found"
    End If
    End Sub

  4. #4
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    By the way i got that from a thread by nice!

  5. #5
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188

    Autorun

    Just in case:
    The autorun file should be something like:
    You can add lots more stuff into it!

    [autorun]
    OPEN=autorun.exe
    ICON=sky.ico

  6. #6
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    From VBWorld, if the function below retruns an empty string the app isn't present on the user's system:


    Looking to find the executable for a particular file extension? This code snippet has the answer.

    Just pass it the extension - such as TXT or MDB - and it'll return the associated Windows program.

    It works by using the FindExecutable API call to locate the executable.
    However this requires an actual file with the requested extension, which is created with another couple of calls.
    The temporary file is deleted after the process has finished.

    To use this code, call GetAssociatedExecutable, passing in the extension as a string.

    Usage

    Code:
    x = GetAssociatedExecutable("MDB")
    Code
    
    Private Declare Function FindExecutable Lib _
        "shell32.dll" Alias "FindExecutableA" _
        (ByVal lpFile As String, ByVal lpDirectory _
        As String, ByVal lpResult As String) As Long
    
    Private Declare Function GetTempFileName Lib _
        "kernel32" Alias "GetTempFileNameA" (ByVal _
        lpszPath As String, ByVal lpPrefixString _
        As String, ByVal wUnique As Long, ByVal _
        lpTempFileName As String) As Long
    
    Private Declare Function GetTempPath Lib _
        "kernel32" Alias "GetTempPathA" (ByVal _
        nBufferLength As Long, ByVal lpBuffer As _
        String) As Long
    
    Public Function GetAssociatedExecutable(ByVal _
        Extension As String) As String
    
        Dim Path As String
        Dim FileName As String
        Dim nRet As Long
        Const MAX_PATH As Long = 260
        
        'Create a tempfile
        Path = String$(MAX_PATH, 0)
        
        If GetTempPath(MAX_PATH, Path) Then
            FileName = String$(MAX_PATH, 0)
        
            If GetTempFileName(Path, "~", 0, FileName) Then
                FileName = Left$(FileName, _
                    InStr(FileName, vbNullChar) - 1)
            
                'Rename it To use supplied extension
                Name FileName As Left$(FileName, _
                    InStr(FileName, ".")) & Extension
                    FileName = Left$(FileName, _
                    InStr(FileName, ".")) & Extension
            
                'Get name of associated EXE
                Path = String$(MAX_PATH, 0)
            
                Call FindExecutable(FileName, _
                    vbNullString, Path)
                GetAssociatedExecutable = Left$( _
                    Path, InStr(Path, vbNullChar) - 1)
            
                'Clean up
                Kill FileName
            
            End If
        
        End If
    
    End Function

  7. #7
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628
    that sort of works, but it doesnt account for newer versions of the program.
    Adobe Acrobat reader is 5.0 now i think.
    You should just run the setup for it in all cases. If it is already on the system and doesn't need to be updated, the setup will exit.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  8. #8
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    That's a good point there!!!

    Also, I'll add one other, if you use any of the codes above, you'll need to place them in a new program.

    The Autorun file from a cd only opens *.EXE program files - you can't do any fancy coding here. Beacon's example was how the autorun works, so if you do go this method, shove the code into an app, make it into an exe and place it on the root of the cd. You can then create an autorun.inf file which then opens your program :

    [autorun]
    OPEN=Your_program.exe
    ICON=Your_Program.exe

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  9. #9
    MerryVIP
    Guest
    I've made a program for editing autorun.inf. You can get it at my homepage, if interested. It is just way nice to set icons on your hard disks

    Program name is Drive icons.


    Btw, if there's multiple icons in the file, you can use them like this:

    ICON=program.dll,12

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