Question Locked

VB.Net how to launch default programs & ERROR: .exe not closing

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Ok, I?m working on a program and have encountered 2 snags.

1 - I need to launch the default program for certain files. For web addresses I need to launch the users default web browser. For txt. Files I would need to run Notepad. For .chm files I would need to run Microsoft HTML Help Executeable. The current line of code I?m trying to use is:

System.Diagnostics.Process.Start("http://www.webaddress.com")

Now that may be the right code to use, and any confirmation or advice would be helpful. I do not know if that code works because of the second problems. After I compile the program and run it to test it, I cannot run it again, I get the following error:

Error 1 Unable to copy file "obj\Release\Project.exe" to "bin\Release\Project.exe". The process cannot access the file 'bin\Release\Project.exe' because it is being used by another process.

In previous projects it would automatically close all useage of the .exe file, but not now.

I would very much appreciate any advice relating to how to solve these problems. Thanks for looking.

7 replies

by dr dij

let me know

I was trying to do something similar.
I have html files I burn onto CD and distribute, wanted to have autorun.inf start their web browser with the files automatically.

I could put in a probable location for IE but won't always work

by mlo83

Opening a file in Internet explorer isn't a problem, I already had this line of code working fine in my program:

Shell(Chr(34) & "C:\Program Files\Internet Explorer\IEXPLORE.EXE" & Chr(34) & "http://www.webside.com", AppWinStyle.NormalFocus)

That could lauch whatever you want to view in that specific program. I need to make my program open internet sites in the default browser and .chm files in their default program.

Stay tuned though, someone may yet be able to provide us with answers.

by bruce.dimon

Create a text file in the root of your CDROM named autorun.inf. Also put your HTML file in the root directory. The contents of the autorun.inf should be:

[autorun]
shellexecute=ReadMe.htm
icon=CDROM.ICO

Hope that works for you.

by bruce.dimon

You're on the right path but you need to create a new object for the process you're starting.

Dim loadProcess As New System.Diagnostics.Process

loadProcess.Start("C:\Temp\batch Bug.rtf")

I just checked this and it works. It also works for URL's. This is for VB.NET. I'm using 2003 but I think it works in all versions. It does not work in VB6.

Good Luck.

by edwardq

If I understand what the error is.. You launch a program in your code and its not releasing the code program becuase its waiting for what you launched to close?

I wrote a interface that had a help system written using the cfm. I used.
Shell("C:\WINDOWS\hh.exe C:\CardDoor\CardHelp.chm", AppWinStyle.NormalFocus, False)

the c:\windows\hh.exe is the windows help reader. False is Dont wait for the program.

Ed..

by nativman

'to run and exe file like notepad, comand 'prompt and etc. in windows i use this code

'declaration
dim me as new system.diagnostic.process()
dim s as string

'body - assign a button to do this.
s = inputbox("Exe Runner")
me = process.start (s)

' hope it help you

This discussion is closed to new replies.