Hi,
I need help with Shell command in VB 2008 Exp. edition. I have create GUI which will run from CD and it have text labels for different options. Everything works fine when I tested from hdd but I don't know what path to enter for disk drives...as you know its different for each machine. Below is code which works with path to hdd:
If e.Node.Text.StartsWith("Study") Then
Shell("""C:\Program Files\Microsoft Office\Office12\winword.exe"" ""F:\Course\Network.doc""", AppWinStyle.NormalFocus, False)
End If
but when I try to replace hdd path with relative path I got an error that file cannot be found. The changed path is:
If e.Node.Text.StartsWith("Study") Then
Shell("""C:\Program Files\Microsoft Office\Office12\winword.exe"" ""..\Course\Network.doc""", AppWinStyle.NormalFocus, False)
End If
So, I need help with Shell command which will open files or run applications from CD disks...not from hdd's. Thanks a lot in advance. Regards, D.
Nebeski |
| Denny72 Tuesday, October 13, 2009 9:04 PM |
If your app was in the root of the CD then:
Application.StartupPath.Substring(0, 6)
should generate an exception as the path is not long enough.
As you have not mentioned that I do wonder where you app really is?
I created a simple program with a single button which called:
Try Process.Start("course\network.doc") Catch ex As Exception MsgBox(ex.Message) End Try
I then stuck it on a CD with a document (network.doc) in a folder called course and ran it. It worked as expected.
There is something wrong with your disc structure.
<Edit>
Looking at your disc structure it looks like you have created an installation disc for your program which is not the impression I gained from your first question. I thought you had written your application executable to the disc.
<Further edit>
If your autorun.inf is calling setup.exe then your disc will probably be installing your application onto the hard drive of the computer. It will then run the application - but the application itself isn't on the CD, it's been installed to the hard drive so won't work as expected.
I think you need to clarify just what you are trying to do as the thread title is "Running application from CD" and that doesn't appear to be what you are doing.
- Marked As Answer byJeff ShanMSFT, ModeratorMonday, October 19, 2009 3:27 AM
-
|
| Dave299 Tuesday, October 13, 2009 11:23 PM |
|
| Malange Tuesday, October 13, 2009 9:16 PM |
Sorry, I do check all of it but cannot find solution. What I tried additionaly is:
Private Sub TreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
If e.Node.Text.StartsWith("Study") Then
Dim theDriveLetter As String = Application.StartupPath.Substring(0, 6)
Process.Start(theDriveLetter & """Network.doc""")
End If
I need advice for next step... D.
Nebeski |
| Denny72 Tuesday, October 13, 2009 10:05 PM |
Where is your application installed on the CD? |
| Dave299 Tuesday, October 13, 2009 10:15 PM |
In the root of the disk Nebeski |
| Denny72 Tuesday, October 13, 2009 10:16 PM |
So what is the purpose of Application.StartupPath.Substring(0, 6)
Does it not work if you just use Process.Start("course\Network.doc") |
| Dave299 Tuesday, October 13, 2009 10:20 PM |
As much I can figure out its should be path for drive where is CD inserted.... No, it doesn't work that is the problem.....I have tried over 30 different solutions and simply don't know what else can I do... I do create instaler with GUI and create disk installation. That part works. Additionaly I do add required applications and files and burn all of it on CD. CD root look like this: - root - Application files (folder created by VB) - autorun.inf - Study application (which is application manifest) - setup.exe - custom file.doc - custom file2.doc - custom file3.pdf - wordviewer.exe - pptviewer.exe
Autorun and application installation works fine but when I click on predefined text label to open custom file2.doc (for example) I got a message file not found.
Any solution, pls and tnx D. Nebeski |
| Denny72 Tuesday, October 13, 2009 10:33 PM |
If your app was in the root of the CD then:
Application.StartupPath.Substring(0, 6)
should generate an exception as the path is not long enough.
As you have not mentioned that I do wonder where you app really is?
I created a simple program with a single button which called:
Try Process.Start("course\network.doc") Catch ex As Exception MsgBox(ex.Message) End Try
I then stuck it on a CD with a document (network.doc) in a folder called course and ran it. It worked as expected.
There is something wrong with your disc structure.
<Edit>
Looking at your disc structure it looks like you have created an installation disc for your program which is not the impression I gained from your first question. I thought you had written your application executable to the disc.
<Further edit>
If your autorun.inf is calling setup.exe then your disc will probably be installing your application onto the hard drive of the computer. It will then run the application - but the application itself isn't on the CD, it's been installed to the hard drive so won't work as expected.
I think you need to clarify just what you are trying to do as the thread title is "Running application from CD" and that doesn't appear to be what you are doing.
- Marked As Answer byJeff ShanMSFT, ModeratorMonday, October 19, 2009 3:27 AM
-
|
| Dave299 Tuesday, October 13, 2009 11:23 PM |
I do what you said and result is....
Nebeski - Edited byDenny72 Tuesday, October 13, 2009 11:58 PMYes, application should be installed onto hdd but custom files and additional applications (wordviewer for example) should be still on CD and my app should access to it from CD
-
|
| Denny72 Tuesday, October 13, 2009 11:44 PM |
Thread title - VB 2008 - Running application from CD...HOW?
Where is your application installed on the CD? - In the root of the disk
"Yes, application should be installed onto hdd but custom files and additional applications (wordviewer for example) should be still on CD and my app should access to it from CD"
You're wasting my time. |
| Dave299 Wednesday, October 14, 2009 12:12 AM |
That is not my itention..you just mis understend me... First: I do create my installation (setup.exe) which is stored in the root of the CD but when disk is insetred it will be installed on the host hdd, but! Second: My application (which is now installed on hdd) should access custom files or other installations on CD! I cannot be more specific! Nebeski |
| Denny72 Wednesday, October 14, 2009 12:18 AM |
That is a completely different question to the one you started this thread with.
Your original question has been answered. I suggest you start a new thread. |
| Dave299 Wednesday, October 14, 2009 9:33 AM |