Results 1 to 38 of 38

Thread: Mount and start a iso file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Mount and start a iso file

    Question:
    Is there a option to mount a isofile (example a game) en start it in een VB program.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Mount and start a iso file

    OpenVirtualDisk function, AttachVirtualDisk function, etc. but .ISO files require Windows 8 or later.

    The calling context also requires the SE_MANAGE_VOLUME_PRIVILEGE access right, and usually this means running elevated.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Thanks but im not so good in VB.
    Can jou help me with a little setup for the program?

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,909

    Re: Mount and start a iso file

    If you are not experienced in VB then maybe better try AutoHotKey for these kind of scripts
    https://www.google.de/search?q=autoh...ount+iso+image

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Thanks

    I have read many on this link it works not on VB6.
    I'm looking for a VB6 script.
    VB6 is instald on my laptop

    I'm running win 10

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Mount and start a iso file

    VBScript is not VB6.

  7. #7
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    It very easy as far as you are using Windows 10, just pass the ISO file path to the following Sub

    Code:
    Private Sub Mount_ISO_File(ByVal strFile As String)
        Shell Environ$("windir") & "\explorer.exe" & " " & strFile, vbNormalFocus
    End Sub



  8. #8

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I have search many pages on the internet but dont know where i put the file path.

    Also i changed my mind.
    While seaching i see that there is al file list box.

    Thinking loud:
    I want the drive D: (standard drive no changing options)
    Directory Games (standard directorie no changing options)
    En show all files in a file list box (the ISO file)
    When i select one file in the box it wil start .
    Is this posible?

  9. #9
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Yes it's possible, first mount the ISO file using above method (post #7), once it's mounted you can browse it with Drive, Dir and File controls.



  10. #10
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Here is a working code, start new project, add Drive1, Dir1 and File1

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Mount_ISO_File "path\to\an\ISO\file"
        
        If IsMounted Then
            'Switch to the mounted drive. (usually it will be the last one)
            Drive1.Drive = Drive1.List(Drive1.ListCount - 1)
            MsgBox "The ISO file is ready to use.", vbInformation
        Else
            MsgBox "Cannot mount the ISO file!", vbExclamation
        End If
    End Sub
    
    Private Sub Drive1_Change()
        Dir1.Path = Drive1.Drive
    End Sub
    
    Private Sub Dir1_Change()
        File1.Path = Dir1.Path
    End Sub
    
    Private Sub File1_Click()
        If Right$(File1.Path, 1) = "\" Then
            Shell File1.Path & File1.FileName
        Else
            Shell File1.Path & "\" & File1.FileName
        End If
    End Sub
    
    Private Sub Mount_ISO_File(ByVal strFile As String)
        Shell Environ$("windir") & "\explorer.exe" & " " & strFile, vbMinimizedNoFocus
    End Sub
    
    Private Function IsMounted() As Boolean
        Dim lngOldCount As Long
        Dim sngTimeOut As Single
        
        lngOldCount = Drive1.ListCount
        sngTimeOut = Timer
        ' Wait until the ISO file mounted or passing 5 seconds without something happen, e.g. the file already mounted
        Do
            Drive1.Refresh
        Loop Until (Drive1.ListCount > lngOldCount) Or (Timer > sngTimeOut + 5)
        IsMounted = (Drive1.ListCount > lngOldCount)
    End Function



  11. #11

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Wow thanks..

    I get errors
    1: at the start up i get a box with the message "Cannot mount the ISO file!"
    2: by select the drive, the directory en then the iso file i ged a run-time error 5: invalid procedure call or argument.

    When i click debug is on Shell File1.Path & "\" & File1.FileName.
    And the ISO file wil not start..

  12. #12
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    1: at the start up i get a box with the message "Cannot mount the ISO file!"
    This is happen if the ISO already mounted, try to check if the ISO drive letter exist before calling Mount_ISO_File

    2: by select the drive, the directory en then the iso file i ged a run-time error 5: invalid procedure call or argument.
    Shell used to run app file (*.exe), so if you select other file type e.g. *.txt then you must run the app you want to open the file with and pass that file to the app, here is an example for text files

    Code:
    Private Sub File1_Click()
        Dim strPath As String
        strPath = File1.Path
        If Right$(strPath, 1) <> "\" Then
            strPath = strPath & "\"
        End If
        Shell Environ$("windir") & "\notepad.exe" & " " & strPath & File1.FileName
    End Sub



  13. #13

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Even when i select a .exe file i get the same error.


    And when the iso is ready.

    I want to start a new project programm and open the iso file
    I'll make it like before Drive, directory, filelist.
    Bud when i mouseklik on the isofile it wil start a simulation drive and start up.
    Last edited by JTvD; Jan 26th, 2018 at 01:25 PM.

  14. #14
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    So, what's your problem now?

    See this if you want to know more about drives in your PC http://www.vb-helper.com/howto_detai...tructured.html



  15. #15

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    No not many problems only many Help VB6 questions
    And i see here is the kowhow..

    I wish i was that good...


    I have made
    'button min
    Private Sub Command1_Click()
    Form1.WindowState = vbMinimized
    End Sub

    'button stop progam
    Private Sub Command2_Click()
    End
    End Sub

    Private Sub Form_Load()

    File1.Path = "D:\game"
    File1.Pattern = "*.iso"
    End Sub

    Its not muts bud for me a lot ;o)

    It's shows the iso files in the dir Game is a falilistbox
    What i now look for is the part to start it up.

  16. #16
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Don't use End statement, instead use Unload http://www.vbforums.com/showthread.p...load-Me-vs-END

    What i now look for is the part to start it up.
    Start what? Do you mean mount the selected ISO file?



  17. #17

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I mean when i place a iso file like a game on my harddisk en i start this up to play when i stop then is there this VB6 programm to open a new game.

    I have many iso files on my pc en when i go to the directory en klik on it its start up.
    I want to make that in VB

  18. #18
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    I already showed you how to mount an ISO in VB program and how to start an app using Shell

    What i'm understand is that you want to auto start a game in an ISO, the problem is that each game has different exe name, so how to know the game's exe name to auto run it?



  19. #19

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Perhaps i can install all games and when i start the game exe file is wil set de iso file to a simulation cd/dvd and start de game.
    It will only start when the game's cd/dvd is in a simulation drive.

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I tried to change it a littlebit..
    Bud it don't work

    It show the EXE file bud when i start up i get a debug error

    Dim F As Form


    'button min
    Private Sub Command1_Click()
    Form1.WindowState = vbMinimized
    End Sub

    'button close all forms
    Private Sub Command2_Click()

    For Each F In Forms
    If F.Name <> Me.Name Then
    Unload F
    End If
    Next
    Unload Me
    End Sub


    Private Sub File1_Click()
    Dim strPath As String
    strPath = File1.Path
    If Right$(strPath, 1) <> "\" Then
    strPath = strPath & "\"
    End If
    Shell Environ$("windir") & "Strike Team Hydra.exe" & " " & strPath & File1.FileName
    End Sub

    Private Sub Form_Load()
    File1.Path = "C:\Program Files\Strike Team Hydra"
    File1.Pattern = "*.exe"
    End Sub
    Last edited by JTvD; Jan 27th, 2018 at 04:14 PM.

  21. #21
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Replace
    Code:
    Shell Environ$("windir") & "Strike Team Hydra.exe" & " " & strPath & File1.FileName
    with
    Code:
    Shell strPath & File1.FileName
    Enclose your code in [code][ /code] tag
    Code:
    Dim F As Form
    'button min
    
    Private Sub Command1_Click()
        Form1.WindowState = vbMinimized
    End Sub
    
    'button close all forms
    
    Private Sub Command2_Click()
        For Each F In Forms
            If F.Name <> Me.Name Then
                Unload F
            End If
        Next
        Unload Me
    End Sub
    
    Private Sub File1_Click()
        Dim strPath As String
        strPath = File1.Path
        If Right$(strPath, 1) <> "\" Then
            strPath = strPath & "\"
        End If
        Shell strPath & File1.FileName
    End Sub
    
    Private Sub Form_Load()
        File1.Path = "C:\Program Files\Strike Team Hydra"
        File1.Pattern = "*.exe"
    End Sub



  22. #22

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Wow this works...

    Wunderfull many thanks.

    I hope i'll learn it a little bit more.
    I'ts nice to see a programm that works..

  23. #23
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    If you have many games and want to run from one list then you can store information about each game in file and run according this info

    the attached project is a simple way to do that, all you have to do is editing the file "game list.txt" and store info about your games, each line of that file consist of three field separated by "|"
    1- The game title e.g. Strike Team Hydra
    2- The full path to the game exe file e.g. C:\Program Files\Strike Team Hydra\Strike Team Hydra.exe
    3- (optional) The full path to the game ISO file e.g. D:\games\Strike Team Hydra.iso
    Attached Files Attached Files



  24. #24

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Youre program finisit it all.

    This is very nice.. Thanks a lot..

  25. #25

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Can i ask you a question.

    If no ISO needed.. it starts a dir window.
    Is is posible to make "if no ISO needed then onlye start the instald game"

  26. #26
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Quote Originally Posted by JTvD View Post
    Is is posible to make "if no ISO needed then onlye start the instald game"
    Yes, as i said the third field is optional, so you can omit it e.g.
    Code:
    Strike Team Hydra|C:\Program Files\Strike Team Hydra\Strike Team Hydra.exe
    Note that the last delimiter is omitted too.



  27. #27

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Ah that's true the optional i missed, i have seen your program and stop reading..

    Then a other question.. if i ask to muts just say it and i'll stop.

    To make the program even nicer to look at i want to set a picture from the selected game i a picurebox or something.

    I want to try it myself..
    Wath's the part from the program when i have selected a game before i press run?

    I let you see what i have don in the program so you can tel why it not work or make in better
    Last edited by JTvD; Jan 29th, 2018 at 03:10 PM.

  28. #28

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I have found it with "List1.Text" i kan change te picture.
    With a little cut and past.

    If the picture have the same name as the game it shows the picture in the picture box.
    One thing i can't find.
    Now its onley the JPG files, bud how cam i put more types pictures as bmp, of even een gif


    Private Sub List1_Click()
    Dim sFile As String
    Dim lLen As Long
    sFile = "D:\game\" & List1.Text & ".jpg"
    On Error Resume Next
    lLen = FileLen(sFile)
    If Err Then
    Picture1.Picture = Nothing
    Else
    Picture1.Picture = LoadPicture(sFile)
    End If
    On Error GoTo 0

    End Sub

  29. #29
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    It is better to use the advanced ListView control, Microsoft Visual Basic 6.0 Common Controls must be installed in your system

    Try the new launcher
    Attached Files Attached Files



  30. #30

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I have a problem.

    This part read the .TxT file for info game.
    Bud when the .TxT file exist i get a error.
    "On error resume next" it freese the program

    Can you help me to make that if the .TxT file not exist the Text1.text = No ino.

    My code: (found on the internet) It works solong the .TxT file is there

    Dim dText As String
    Dim sString1 As String, sString2 As String

    Open "D:\game\" & List1.Text & ".TxT" For Input As #1
    Do While Not EOF(1)
    Input #1, sString1, sString2
    dText = dText & sString1 & ", " & sString2 & vbCrLf
    Loop
    Text1.Text = dText
    Close

  31. #31
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    The last attached code (post #29) contains a function named IsFileExist, add it to your project and call it before trying to open any file, e.g.

    Code:
    If IsFileExist(file path) Then
        ' it's exist, open it.
    Else
        ' Show warning message
    End If



  32. #32

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I tried the IsFilkeExist bud where ever i put it i get a error.
    I don't know where to put it and how to write


    Meaby can you help me with this:

    I tried"on error goto 0
    and by 0 text1.text gives the text "No game info"

    Is this posible i get the same debug error as in post 30

    Private Sub List1_Click()
    Dim sFile As String
    Dim lLen As Long
    'load game picture
    sFile = "D:\game\" & List1.Text & ".jpg"
    On Error Resume Next
    lLen = FileLen(sFile)
    If Err Then
    Picture1.Picture = Nothing
    Else
    Picture1.Picture = LoadPicture(sFile)
    End If

    'load game text
    On Error GoTo 0
    Dim dText As String
    Dim sString1 As String, sString2 As String

    Open "D:\game\" & List1.Text & ".TxT" For Input As #1
    Do While Not EOF(1)
    Input #1, sString1, sString2
    dText = dText & sString1 & ", " & sString2 & vbCrLf
    Loop
    On Error GoTo 0

    Text1.Text = dText
    Close
    0
    Text1.Text = "No Game info"
    End Sub

  33. #33
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    I tried the IsFilkeExist bud where ever i put it i get a error.
    How can i help you without telling me what is the error message!

    I don't know where to put it and how to write
    Put the function in the same form where you are need to use it.



  34. #34

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    When the TxT file exist there is no problem it works fine

    The problem is that the program tries to read a textfile that not exist.
    I tried on error go to 0 bud no succes. it dosnt work

    Runtime errot 53
    "file not exist"
    When i press Debug its on the part:Open "D:\game\" & List1.Text & ".TxT" For Input As #1
    On Error GoTo 0
    Dim dText As String
    Dim sString1 As String, sString2 As String

    Open "D:\game\" & List1.Text & ".TxT" For Input As #1
    Do While Not EOF(1)
    Input #1, sString1, sString2
    dText = dText & sString1 & ", " & sString2 & vbCrLf
    Loop
    On Error GoTo 0

    Text1.Text = dText
    Close
    0
    Text1.Text = "No Game info"
    End Sub
    Last edited by JTvD; Feb 1st, 2018 at 03:55 PM.

  35. #35
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    Try this
    Code:
    Private Sub List1_Click()
        Dim sDir As String
        sDir = "D:\game\"
        
        'load game picture, try to load jpg, gif or bmp
        If IsFileExist(sDir & List1.Text & ".jpg") Then
            Picture1.Picture = LoadPicture(sDir & List1.Text & ".jpg")
        ElseIf IsFileExist(sDir & List1.Text & ".gif") Then
            Picture1.Picture = LoadPicture(sDir & List1.Text & ".gif")
        ElseIf IsFileExist(sDir & List1.Text & ".bmp") Then
            Picture1.Picture = LoadPicture(sDir & List1.Text & ".bmp")
        Else
            Picture1.Picture = Nothing
        End If
        
        'load game text
        If IsFileExist(sDir & List1.Text & ".txt") Then
            Dim dText As String
            Dim sString1 As String, sString2 As String
            Dim lFileNumber As Long
            lFileNumber = FreeFile
            
            Open sDir & List1.Text & ".txt" For Input As #lFileNumber
            Do While Not EOF(1)
                Input #lFileNumber, sString1, sString2
                dText = dText & sString1 & ", " & sString2 & vbCrLf
            Loop
            Close #lFileNumber
            Text1.Text = dText
        Else
            Text1.Text = "No Game info"
        End If
    End Sub
    
    Private Function IsFileExist(strFile As String) As Boolean
        IsFileExist = (Dir(strFile) <> vbNullString)
    End Function



  36. #36

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    Youre realy fantastic...
    It works..
    Many thanks.

  37. #37

    Thread Starter
    Lively Member
    Join Date
    Feb 2012
    Posts
    68

    Re: Mount and start a iso file

    I have finnised it and make it an .exe file.

    One problem is that i move the exe file for example to the desktop.
    I get a error.
    Is this from this part "App.path"
    When i left it in the app dir where it was saved in VB6 the it works fine.

    The error is Run=time error '380' Invalid propety value

  38. #38
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Mount and start a iso file

    The main question of this thread has been resolved, please start a new thread for the new issue and post the line caused the error 380



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