Solved

Installing Network Protocols

Posted on 2004-09-07
9
180 Views
Last Modified: 2010-04-23
I have searched EE and multiple forum sites for 20+ hours now and am coming up with nothing at all. I need a way to automate the installation of RASPPPOE in Windows 98/ME/2k using VB.NET and INF files. The protocol itself can be added manually through Network Neighborhood but I am trying to simplify everything for the end user - they click, say.. "Setup" and it handles everything else for the person automatically. I can create the connection once the protocol is installed but it's getting the protocol installed that is driving me insane.

Yes, the project is in .Net but I will be using the bootstrapper program to allow installation of the .Net framework if is needed so I can fully utilize any classes easily.

The protocol is stored in an .inf file (there are a couple of them) and they also have DLL's associated with them as well as two .sys files. I need to get this installed for the person and then I'll create the connection afterwards.

Does anyone have any suggestions? I'm beating my head against the wall on this one..
0
Comment
Question by:goconcepts
  • 5
9 Comments
 
LVL 5

Expert Comment

by:thenrich
ID: 12005728
I'm not sure what the proper syntax would be but I'd think you'd be able to create a batch (.bat) file to accomplish this and run it from your app.
0
 

Author Comment

by:goconcepts
ID: 12006930
I'll give that one a try and post here what I find, if anything. Thanks for the suggestion!

I'm going to leave this open for now and see if anyone else has any suggestions.
0
 

Author Comment

by:goconcepts
ID: 12007052
I was just browsing and came across this on www.dotnet247.com. You would need to import Microsoft.Win32 and System.IO and it looks like this will install the INF file. Does anyone have any experience with this? What would the function actually return? A 1 for yet and 2 for no as to whether it was successful? Also, can anyone decipher this a little for me? I could most likely get it working but I'd really like to understand the why factor...what is making this work the way it is supposed to?

Imports System.IO
Imports Microsoft.Win32

Public Function InstallInfFile(ByVal strFileName As String) As Boolean
Dim strClassName As String = ""
Dim strInstallCommand As String = ""
Dim blnInstallationSuccess As Boolean = False
Dim objSubKey As RegistryKey

strFileName = strFileName.Trim

'Do a basic check to ensure that the specified file is an INF file and actually exists

If (strFileName.Length >= 4) AndAlso (strFileName.Substring(strFileName.Length - 4, 4).ToUpper = ".INF") AndAlso File.Exists(strFileName) Then
'Get the command from the regitry that is used to install INF files

objSubKey = Registry.LocalMachine.OpenSubKey("Software\Classes\.inf")

If Not IsNothing(objSubKey) Then
strClassName = objSubKey.GetValue("").Trim

objSubKey.Close()

If (strClassName.Length > 0) Then
objSubKey = Registry.LocalMachine.OpenSubKey("Software\Classes\" & strClassName & "\shell\Install\command")

If Not IsNothing(objSubKey) Then
strInstallCommand = objSubKey.GetValue("").Trim

objSubKey.Close()
End If
End If
End If

'Check that the expected argument placeholder exists at the end of the string

If (strInstallCommand.Length > 3) AndAlso (strInstallCommand.Substring(strInstallCommand.Length - 3, 3) = " %1") Then
'Replace the argument placeholder with the name of the INF file

strInstallCommand = strInstallCommand.Substring(0, strInstallCommand.Length - 2) & strFileName

'Install the INF file

blnInstallationSuccess = (Shell(strInstallCommand, AppWinStyle.Hide, True) = 0)
End If
End If

Return blnInstallationSuccess
End Function
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:goconcepts
ID: 12009497
I've doen some rearranging of the code above as that wasn't doing anything for me (I kept getting JIT errors about converting a string to a double. Here is all current code I am using and everything works up until the point of the installation itself. It finds the file and then attempts the install but I'm assuming it fails because it returns the MsgBox("Failed") window at the end.

Can anyone see what I'm doing wrong? The "Beginning the install.." box pops up but then I just get a failed return, there isn't any error with the try/catch block.

********************************************************************
Private Sub cmdInstall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInstall.Click
        Dim strFileName As String = "NETPPPOE.INF"
        'installINFfile(strFileName)
        If installINFfile(strFileName) = True Then
            MsgBox("Success")
        ElseIf installINFfile(strFileName) = False Then
            MsgBox("Failed")
        End If
    End Sub

    Private Function installINFfile(ByVal strFileName As String) As Boolean
        Dim strClassName As String = ""
        Dim strInstallCommand As String = ""
        Dim blnInstallationSuccess As Boolean = False
        Dim objSubKey As RegistryKey

        strFileName = strFileName.Trim
        'MsgBox("Everything is good on 81")

        'If File.Exists(strFileName) Then
        '    MsgBox("Found it")
        'Else
        '    MsgBox("Not included")
        'End If

        'Do a basic check to ensure the specified file is an INF file and actually exists
        'AndAlso (strFileName.Substring(strFileName.Length - 4, 4).ToUpper = ".INF")
        If (strFileName.Length >= 4) AndAlso (strFileName.Substring(strFileName.Length - 4, 4).ToUpper = ".INF") AndAlso File.Exists(strFileName) Then
            'Get the command from the registry that is used to install INF files
            MsgBox("Everything is good on 86")
            objSubKey = Registry.LocalMachine.OpenSubKey("Software\Classes\.inf")
            MsgBox("Everything is good on 88")

            If Not IsNothing(objSubKey) Then
                strClassName = objSubKey.GetValue("").Trim
                objSubKey.Close()
                If (strClassName.Length > 0) Then
                    objSubKey = Registry.LocalMachine.OpenSubKey("Software\Classes\" & strClassName & "\shell\Install\command")
                    If Not IsNothing(objSubKey) Then
                        strInstallCommand = objSubKey.GetValue("").Trim
                        objSubKey.Close()
                    End If
                End If
            End If
            MsgBox("Everything is good on 108 which is right before the actual install")
            'Check that the expected argument placeholder exists at the end of the string
            If (strInstallCommand.Length > 3) AndAlso (strInstallCommand.Substring(strInstallCommand.Length - 3, 3) = "%1") Then
                'Replace the argument placeholder with the name of the INF file
                strInstallCommand = strInstallCommand.Substring(0, strInstallCommand.Length - 2) & strFileName
                'Install the INF file
                MsgBox("Beginning the install..")
                Try
                    blnInstallationSuccess = (Shell(strInstallCommand, AppWinStyle.Hide, True) = 0)
                Catch ex As Exception
                    MsgBox(ex)
                End Try
            End If
        End If
        Return blnInstallationSuccess
    End Function
********************************************************************
0
 

Author Comment

by:goconcepts
ID: 12035655
No one has any thoughts??
0
 

Author Comment

by:goconcepts
ID: 12041279
I've since found the answer to this question and a few points could be given to the one answer received but it didn't really do me any good in the end.

Not sure how I handle this however so I guess I'll just leave it open and 21 days later an admin can close it.
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12313317
PAQed - no points refunded (of 500)

GhostMod
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now