-
Need help to put Code together..
I need this
Code:
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
and this combined
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Process.Start("C:\data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start("C:\data\Malwarebytes\mbam.exe")
End Sub
I am trying to get the program to recognize the CD/DVD drive.... where it is highlighted C:.
The idea of the program is to make a launcher to automatically launch various freeware programs ergo CCleaner,Malwarebytes,SuperAntiSpyware, etc. Once I get the program to recognize what drive it is then I also need to figure out how to make it Start, Close, then start the next one.... So obviously
Code:
Process.Start("C:\data\CCleaner\CCleaner.exe").waitforexit()
Process.Start("C:\data\Malwarebytes\mbam.exe").Waitforexit()
Won't work because the .waitforexit() isn't waiting for exit of CCleaner.. WHY? And could a delay be incorporated into this to make it wait for the .waitforexit()? BTW for you trolls I am very very new to VB so as simple as this may be it is my way of learning so GTFO if you have hate mail.
-
Re: Need help to put Code together..
Trolls don't last long around here.
In this line:
Process.Start("C:\data\CCleaner\CCleaner.exe").WaitForExit()
it appears taht you want to replace the C: with whatever is in your variable. To do that, the line would look like this:
Process.Start(driveletter & "\data\CCleaner\CCleaner.exe").WaitForExit()
Of course, this would only work if driveletter actually has someting, but you mostly have the code for that. There are two issues to consider. The first is whether or not that first code could fail in such a way that driveletter was never set. That seems unlikely, but possible. Therefore, you'd probably want to explicitly check that driveletter was not an empty string.
Combined, they would look like this:
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()
Process.Start(driveLetter & "\data\Malwarebytes\mbam.exe")
Else
Windows.Forms.Messagebox.Show("No Drive Letters Found","Nothing Doing")
End If
End Sub
I don't have an answer for why WaitForExit isn't. Not really my area.
-
Re: Need help to put Code together..
Shaggy, could I ask what a Troll in here means? its the third time I have seen that word in the past week but I do not know what does it refer to.
* If driveletter is getting the root directory it will get something like "D:\", so the line Shaggy proposes would be
Process.Start(driveLetter & "data\CCleaner\CCleaner.exe:).WaitForExit()
notice the lack of the first "\"
But most of all, they are not going to be there because those calls are for the malware software installed in the pc and nothing to do with the cd detected, but you may want to look into a parameter to pass the utility to scan the CD and not the whole PC.
On the other hand, if CCleaner and Malwarebytes are correctly installed then you could run them by just
Process.Start("CCleaner").WaitForExit()
Process.Start("mbam").WaitForExit()
-
Re: Need help to put Code together..
Quote:
Originally Posted by
kaliman79912
Shaggy, could I ask what a Troll in here means? its the third time I have seen that word in the past week but I do not know what does it refer to.
The meaning is somewhat loose, but it generally refers to people who take pleasure at abusing other people. Lots of forums suffer from people who's sole roll in life is to make denigrating comments at others without being helpful. Quite often, this is directed at the ignorance which comes from being new to something. It's a pretty stupid position, because we are all ignorant before we learn, and we are all learning. That type of person is generally removed from this place pretty quickly, which is one of the things I like about it.
Quote:
* If driveletter is getting the root directory it will get something like "D:\", so the line Shaggy proposes would be
Process.Start(driveLetter & "data\CCleaner\CCleaner.exe:).WaitForExit()
notice the lack of the first "\"
Oops. I edited a bit too far when I combined those. Still, the points you made after that are even more significant. I was just combining, without considering whether or not it would really work, but I believe that you are right. What I had posted would only apply (had it not had the typo) if the programs were on the CD. I don't even know whether that is possible, though it does seem like this would allow a person to carry around a CD of cleaner apps that could be run, as needed. So, I guess I don't know whether or not the concept is valid or not.
-
Re: Need help to put Code together..
that is incorrect. the software in question may not be registered as a shortcut type to the system (environment variables for example) so when you do Process.Start("CCleaner") it will not work if it hasnt registered it like this to the system
WaitForExit() does work but there seems to be something wrong somewhere else.
WaitForExit does just that.... its a threadblocking method
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Shaggy Hiker
Trolls don't last long around here.
In this line:
Process.Start("C:\data\CCleaner\CCleaner.exe").WaitForExit()
it appears taht you want to replace the C: with whatever is in your variable. To do that, the line would look like this:
Process.Start(driveletter & "\data\CCleaner\CCleaner.exe").WaitForExit()
Of course, this would only work if driveletter actually has someting, but you mostly have the code for that. There are two issues to consider. The first is whether or not that first code could fail in such a way that driveletter was never set. That seems unlikely, but possible. Therefore, you'd probably want to explicitly check that driveletter was not an empty string.
Combined, they would look like this:
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 & "C:\data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start(driveLetter & "\data\Malwarebytes\mbam.exe")
Else
Windows.Forms.Messagebox.Show("No Drive Letters Found","Nothing Doing")
End If
End Sub
I don't have an answer for why WaitForExit isn't. Not really my area.
I went and tried to place that code in there. Nothing happened it kicked back and said file could not be found...
-
Re: Need help to put Code together..
A troll is someone who goes around not offering any help whatsoever but they are sure to post hate mail. Like "You don't know what you are doing you noob" or "Are you an idiot" things of that nature. They have nothing good to say only bad.
-
Re: Need help to put Code together..
there is an overload of WaitForExit() where you put the number of milliseconds to wait as maximum. But the process exit takes precedence.
Process.WaitForExit(10000)
-
Re: Need help to put Code together..
Boy did I screw up that code. Not only the missing \ that Kaliman pointed out, but I see that I actually left the C: in one of the lines in the final snippet. I've gone back and edited that to correct it.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
kaliman79912
Shaggy, could I ask what a Troll in here means? its the third time I have seen that word in the past week but I do not know what does it refer to.
* If driveletter is getting the root directory it will get something like "D:\", so the line Shaggy proposes would be
Process.Start(driveLetter & "data\CCleaner\CCleaner.exe:).WaitForExit()
notice the lack of the first "\"
But most of all, they are not going to be there because those calls are for the malware software installed in the pc and nothing to do with the cd detected, but you may want to look into a parameter to pass the utility to scan the CD and not the whole PC.
On the other hand, if CCleaner and Malwarebytes are correctly installed then you could run them by just
Process.Start("CCleaner").WaitForExit()
Process.Start("mbam").WaitForExit()
Actually I just want the program to locate the CD/DVD drive because that is where I ahve the CCleaner and mbam and all that other mumbo jumbo installed at.(on the CD) but if i leave it as process.start(ccleaner.exe).waitforexit() then it will come back and say file could not be found because it is installed on the CD not the PC. That is why I need it to have a directory.
-
Re: Need help to put Code together..
with the code supplied, it will work now. as long as the path exists and file exists... then of course when you start the process, it will work otherwise... you will get the exception that the file/path was not found
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
with the code supplied, it will work now. as long as the path exists and file exists... then of course when you start the process, it will work otherwise... you will get the exception that the file/path was not found
Not working I have checked and double checked the directories and the files they exist where they are supposed to be but it is still unhandled.
-
Re: Need help to put Code together..
ok if its unhandled.... then that tells you something. if the file/folder was not found then that is correct. not found
can you paste and inspect the file path/folder the code is obtaining against the actual location. if there is a difference - thats the problem.
-
Re: Need help to put Code together..
Do this:
if File.Exists(driveLetter & "data\CCleaner\CCleaner.exe") then MessageBox.Show("File exists")
else MessageBox.Show("Not exists")
-
Re: Need help to put Code together..
but does the process start? or does your program just dont wait for it to exit?
-
Re: Need help to put Code together..
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()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
Else
Windows.Forms.MessageBox.Show("If you got this message then go home.", "Ooop's We messed up.")
End If
End Sub
That's what I have... Still isn't working and I assure you the files are located at D:\data\CCleaner\CCleaner.exe and D:\data\Malwarebytes\mbam.exe.
-
Re: Need help to put Code together..
the poster indicated it did not start and throws an Exception saying that the file was not found
-
Re: Need help to put Code together..
Quote:
Originally Posted by
kaliman79912
but does the process start? or does your program just dont wait for it to exit?
LOL right now I just need to get it to launch the program when the CD/DVD drive letter isn't blatantly put out there then I will move to that problem xD
-
Re: Need help to put Code together..
did you do the suggestion I posted for debugging purposes? :)
did you step through the code line by line and inspecting the values, seeing if they are sane?
-
Re: Need help to put Code together..
I have a feeling the problem lies here somewhere. It isn't the directory.
Code:
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
So.... any ideas? I am 110% stumped...
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
did you do the suggestion I posted for debugging purposes? :)
did you step through the code line by line and inspecting the values, seeing if they are sane?
I tried removing the "\" but it didn't change anything still an unhandled exception file not found jada jada BS... XD
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Matthew.Kaulfers
I have a feeling the problem lies here somewhere. It isn't the directory.
Code:
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
So.... any ideas? I am 110% stumped...
I think it was mentioned before, there is a \ missing at the beginning. include it but I cannot remember if the DriveLetter will contain a leading backslash, so for sanity sake now:
Code:
if not driveletter.EndsWith("\") then driveletter = driveletter & "\"
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
again, did you do the suggestion I had posted? :)
-
Re: Need help to put Code together..
if the file wasnt found then clearly the path being constructed is incorrect. .NET/computer doesnt lie :)
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Matthew.Kaulfers
Actually I just want the program to locate the CD/DVD drive because that is where I ahve the CCleaner and mbam and all that other mumbo jumbo installed at.(on the CD) but if i leave it as process.start(ccleaner.exe).waitforexit() then it will come back and say file could not be found because it is installed on the CD not the PC. That is why I need it to have a directory.
The poster said that if he leaves it as process.start(ccleaner.exe).waitforexit() then it will come back and say file could not be found.
So the question was valid.
You may want to do other validation as you can have more than one CD on the PC and your loop will only remember the last one. Or if you have a virtual drive is almost always detected as a CD. Even some USB Flash Drives register as CD.
Do as Teco said and put a breakpoint and look at the contents of driveletter
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
I think it was mentioned before, there is a \ missing at the beginning. include it but I cannot remember if the DriveLetter will contain a leading backslash, so for sanity sake now:
Code:
if not driveletter.EndsWith("\") then driveletter = driveletter & "\"
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
again, did you do the suggestion I had posted? :)
Did as you suggested :) to no avail :(
-
Re: Need help to put Code together..
Did you stop the code with a breakpoint and step through it looking at the variables? particulary driveLetter?
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Matthew.Kaulfers
Did as you suggested :) to no avail :(
you didnt quite do what I said :)
print out the path to a messagebox. what does it say?
-
Re: Need help to put Code together..
Another test you can do is to put the whole path as you know it is right now instead of the detected drive. Something like:
"D:\CCleaner\CCleaner.exe"
does it work that way?
-
Re: Need help to put Code together..
the user indicated that it does work hardcoding it.... they dont want it hardcoded.
the problem is clear - the file is not found. the path is formed incorrectly.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
the user indicated that it does work hardcoding it.... they dont want it hardcoded.
the problem is clear - the file is not found. the path is formed incorrectly.
Again... The user oroginally hardcoded it using his hard drive. Now he is trying to use the CD drive.
Please read the posts before dismissing everything I write. This is the second time in this thread that you have mistakenly corrected me.
-
Re: Need help to put Code together..
we are all trying to help kaliman :) relax. sorry you feel that way but nothing I can do about that. in future I wont contribute.
its a community effort, a team effort, not an individual effort. if you cannot accept this then really it wont work. needlessly to say no one is perfect... and you arent either.
things like this is off putting to everyone.
ill leave it here for now.
I wish the OP the best in this problem and im sure its easily resolved.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
kaliman79912
Another test you can do is to put the whole path as you know it is right now instead of the detected drive. Something like:
"D:\CCleaner\CCleaner.exe"
does it work that way?
It does launch whenever i put
process.start("D:\data\CCleaner\CCleaner.exe").waitforexit()
Not perfectly but it does find the file.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
kaliman79912
Again... The user oroginally hardcoded it using his hard drive. Now he is trying to use the CD drive.
Please read the posts before dismissing everything I write. This is the second time in this thread that you have mistakenly corrected me.
Yes I originally hardcoded with the "D:\" but that is a random variable from PC to PC. Lets not get upset over this thing I appreciate help from all. And I am trying each individual idea to see if we can work this thing out. Thanks kaliman I probably should have said that originally but it is my fault for the confusion.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
the user indicated that it does work hardcoding it.... they dont want it hardcoded.
the problem is clear - the file is not found. the path is formed incorrectly.
Is there a different way to code it to find the drive in a different manner?? It isn't the file being in the wrong way I believe we are just pointing it in the wrong direction.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Techno
we are all trying to help kaliman :) relax. sorry you feel that way but nothing I can do about that. in future I wont contribute.
its a community effort, a team effort, not an individual effort. if you cannot accept this then really it wont work. needlessly to say no one is perfect... and you arent either.
things like this is off putting to everyone.
ill leave it here for now.
I wish the OP the best in this problem and im sure its easily resolved.
Please continue to contribute. This is a program I would love to send to CNet and put some names on. BTW if you continue to help all peoples involved will have their name on this program.
-
Re: Need help to put Code together..
Okay here is what I have now. It doesn't work.
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()
Process.Start(driveletter & "data\Malwarebytes\mbam.exe")
Else
Windows.Forms.MessageBox.Show("If you got this message then go home.", "Ooop's We messed up.")
End If
I tried this and it launches the program but only on "D:" Drive. Won't work in all computers.....
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Process.start("D:\data\CCLeaner\ccleaner.exe").waitforexit()
Process.start("D:\data\malwarebytes\mbam.exe").waitforexit()
End Sub
End Class
So I think the problem is here...
Code:
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
*****************************************************************
Else
Windows.Forms.MessageBox.Show("If you got this message then go home.", "Ooop's We messed up.")
End If
(****) Represents the process.start in which I say again. THE DIRECTORY IS THERE.
-
Re: Need help to put Code together..
Man, glad I went home for dinner.
This is a situation where a bit of debugging is needed. There isn't going to be a good way around this. The code I posted is mostly right, but there is something slightly off about it, and it is probably as Techno suggested: The driveletter is not just the letter. What is it? I don't know. I could find out, but you can find out even faster. Here's how:
Put a breakpoint on this line:
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
when execution stops on the breakpoint, take a look at what is in 'driveletter'. What is it? Next, highlight this portion:
driveletter & "data\CCleaner\CCleaner.exe"
and press Shift+F9. In some way, that is not "D:\data\CCleaner\CCleaner.exe". Either a character is added, or a character is missing. Knowing what the difference is will tell you how to correct the line of code.
-
Re: Need help to put Code together..
When you break it on the first Process.Start(...).WaitForExit(), what does DriveLetter contain? I think that is the issue at hand. It will be helpful to everyone if they knew what DriveLetter contained when the program stopped at the breakpoint. I think everyone is assuming that it is either blank, or it is the correct letter. Post what it says it is.
Note: I just read this from top to bottom, so if you mentioned it in an earlier post, I apologize for forgetting. :)
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Shaggy Hiker
Man, glad I went home for dinner.
This is a situation where a bit of debugging is needed. There isn't going to be a good way around this. The code I posted is mostly right, but there is something slightly off about it, and it is probably as Techno suggested: The driveletter is not just the letter. What is it? I don't know. I could find out, but you can find out even faster. Here's how:
Put a breakpoint on this line:
Process.Start(driveletter & "data\CCleaner\CCleaner.exe").WaitForExit()
when execution stops on the breakpoint, take a look at what is in 'driveletter'. What is it? Next, highlight this portion:
driveletter & "data\CCleaner\CCleaner.exe"
and press Shift+F9. In some way, that is not "D:\data\CCleaner\CCleaner.exe". Either a character is added, or a character is missing. Knowing what the difference is will tell you how to correct the line of code.
Okay waiting for VB to re install. I am on a friends computer. It is almost done. I CAN FEEL WE ARE CLOSE AS idk.... the hair on our jewels... :D
-
Re: Need help to put Code together..
I don't even want to consider that metaphor.
-
Re: Need help to put Code together..
*sigh* I was just too slow. Must learn to read faster.
-
Re: Need help to put Code together..
Didn't I say something like that about my speed just a little while back?
-
Re: Need help to put Code together..
Quote:
Didn't I say something like that about my speed just a little while back?
Quite possibly. I guess that was just payback, huh?
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Shaggy Hiker
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.
-
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.
-
Re: Need help to put Code together..
Quote:
Originally Posted by
Matthew.Kaulfers
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.
:lol::lol: That's the funniest post I've seen in a long time.:lol::lol:
-
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
-
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.
-
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....
-
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
-
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