Page 2 of 2 FirstFirst 12
Results 41 to 51 of 51

Thread: Need help to put Code together..

  1. #41
    Addicted Member
    Join Date
    Nov 2011
    Posts
    129

    Re: Need help to put Code together..

    *sigh* I was just too slow. Must learn to read faster.
    Click "Rate This Post" if I helped you in any way.

    The best process for finding help.
    Step 1: Google it
    Step 2: Google it again
    Step 3: Google it yet again
    Step 4: Ask on a forum
    Step 5: Go to Step 1

  2. #42
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,039

    Re: Need help to put Code together..

    Didn't I say something like that about my speed just a little while back?
    My usual boring signature: Nothing

  3. #43
    Addicted Member
    Join Date
    Nov 2011
    Posts
    129

    Re: Need help to put Code together..

    Didn't I say something like that about my speed just a little while back?
    Quite possibly. I guess that was just payback, huh?
    Click "Rate This Post" if I helped you in any way.

    The best process for finding help.
    Step 1: Google it
    Step 2: Google it again
    Step 3: Google it yet again
    Step 4: Ask on a forum
    Step 5: Go to Step 1

  4. #44

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Cool Re: Need help to put Code together..

    Quote Originally Posted by Shaggy Hiker View Post
    I don't even want to consider that metaphor.
    Well doesn't look like I will be working on this tonight my friends computer is apparently unable to meed the system req for VB xD so I will attempt to fix this monday whenever I get to work. I will continue to post variously about this if I come up with some ideas in the meantime. Have a good weekend guys.

  5. #45

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Re: Need help to put Code together..

    I will finish Later. I just posted somewhere I haven't any idea where but okay.... Few too many sips O' Vodka.... Talk to you gents later. I will post as my ideas come along or if i get a chance to work on this thing some more.

  6. #46
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,039

    Re: Need help to put Code together..

    Quote Originally Posted by Matthew.Kaulfers View Post
    I will finish Later. I just posted somewhere I haven't any idea where but okay.... Few too many sips O' Vodka.... Talk to you gents later. I will post as my ideas come along or if i get a chance to work on this thing some more.
    That's the funniest post I've seen in a long time.
    My usual boring signature: Nothing

  7. #47
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    Re: Need help to put Code together..

    I would sugest for such a long and drawn out venture i would be dumping the vb all together and use a simple bat file

    they wait until your done and dont stop they just keep on coming

    a message or 2 might pop up and you can be sure to not need to know the drive letter of anything within a prebuilt environment

    here to talk some more when he is off the bottle

  8. #48
    Hyperactive Member
    Join Date
    Jan 2012
    Location
    Salt Lake City
    Posts
    313

    Re: Need help to put Code together..

    Maybe i missed it, but i would assume your initiating program is being executed from the same CDROM where you have your other programs.

    you can get the drive letter easy enough via:

    Private ReadOnly _baseDirectory As String = Path.GetPathRoot (Assembly.GetExecutingAssembly().Location)

    and then use Path.combine with _baseDirectory and the rest of the path to ccleaner etc:

    dim _ccCleanerPath as string = "bin\ccleaner.exe"

    process.start(path.combine(_baseDir & _ccCleanerPath)

    looping thru all the drive letters is silly. what if there is 4 CDROMS? you arent checking if the drives are ready and are continuing the loop even after finding a CDROM, so your code will always get the last drive letter regardless if it is the accurate drive or not.

    using my code will GUARANTEE you have the proper path for the root drive letter as thats where your executable was launched from.

    get away from concatenating strings to build paths. use path.combine as thats what its there for =)

    in short:


    your CD would have burned to it:

    yourMainProgram.exe
    bin

    where bin is a directory with all your utility exes in it.

  9. #49

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    32

    Thumbs down Re: Need help to put Code together..

    Found the problem.... All i had to do was change "Driveletter" to "D" and then leave the process.start(D:\blah blah blah) and it finds the correct drive letter on the PC. So that works out but now it won't launch it properly however it will Find the correct drive which on this pc is E:/.... ergo here is my code currently

    Code:
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim driveletter As String = ""
            Dim allDrives() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()
            For Each drive As System.IO.DriveInfo In allDrives
                If drive.DriveType = IO.DriveType.CDRom Then
                    'OK Now we have the CDRom
                    driveletter = drive.RootDirectory.ToString()
                End If
            Next
            'Check that there is a letter.
            If driveletter <> String.Empty Then
                Process.Start("driveletter:\data\CCleaner\CCleaner.exe").WaitForExit() 'Changed from \Program Files\ 'Process is a type and cannot be used as an expression.
                Process.Start("driveletter:\data\Spybot - Search & Destroy\SpybotSD.exe") 'Changed from \Program Files\ (x86)
            Else
                Windows.Forms.MessageBox.Show("No Drive Letters Found", "Nothing Doing")
            End If
    It does find the correct drive letter but it still kicks back and says this An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

    Additional information: Unknown error (0x80041002)


    When I add a break to Process.Start("driveletter:\data\CCleaner\CCleaner.exe").
    And I watch it nothing is shown to be wrong with it just what it says in red up there... When I do the shift+F9 it says that it is a type and cannot be used as an expression. However if I take out "driveletter" and replace it with "E:\" then it launches CCleaner....

  10. #50
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,470

    Re: Need help to put Code together..

    driveletter is a string

    you built it that way

    you then add it to your filespec , url or what ever you wan to call it!

    not by name but by "name"

    the url should be

    driveletter &":\data....

    NOT

    "driveletter:\data...

    can you see the difference

    here to talk

  11. #51
    Hyperactive Member
    Join Date
    Jan 2012
    Location
    Salt Lake City
    Posts
    313

    Re: Need help to put Code together..

    Matthew,

    your approach is NOT going to work if there is more than one CDROM drive in a computer for several reasons. First of all, it will ALWAYS return the last drive letter assigned to a CDROM even if your programs are on the first one. this is because you are using a loop without any exit conditions. Moreover, as i already mentioned, you are not checking the IsReady property either, so your program wont work if you dont have the CD in the last drive anyways.

    think of it this way:

    Drive C - hard drive
    Drive D - CDROM
    Drive E - CDROM
    Drive F - CDROM
    Drive G - hard drive

    Your CD is in drive E.

    The way your code is, driveletter will always get assigned to the F drive which is NOT what you want.

    Get rid of that loop (it will never work as you have it now) and use the code i posted above. The only way a loop like that will work is if you check the IsReady property and look for something unique on the CD, like a filename you burned to the root of the disk.

    IMO there isnt much else to help you with in regard to this problem until you address the underlying issues in your code. even if you get what you have working, it WILL break and you will be right back here asking questions (which isnt a problem, but lets save everyone some time!).

    Good luck

Page 2 of 2 FirstFirst 12

Tags for this Thread

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