Page 1 of 2 12 LastLast
Results 1 to 40 of 47

Thread: Linking to files.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Linking to files.

    Hi i have made a little program , however [im new to coding] i dont know how for example when a user clicks file > software i would like the user to go to a program , which is saved in same file as of he vb application.

    Also how for my legal document can i make a pop up box ,not a msg box , with created by ... copyright.. .

    Thankyou , sorry for noobie questions.

    Liam.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Linking to files.

    Welcome to the forums

    1. I don't understand the question...could you supply more details please?
    2. You have two choices...one is a message box, which you don't want. The other is a form.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hello , thankyou for your warm welcome.

    I have made an applaiction with vb. When you open it up at the top is a menu with File > configuration > tutorial>help. In the file menue i have created a commands option along with other options and finally at the bottom a exit option. When someone clicks on commands i would like it to open up a .html file , which is also saved in the same file as the application .

    Thankyou.
    Last edited by mafia; Jul 21st, 2010 at 02:04 AM.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Linking to files.

    vb.net Code:
    1. System.Diagnostics.Process.Start("c:\myfile.htm")
    Change the path and file name to suite your needs.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey thanks that helped , i tried same too launch a .bat which i leave running but didn't work .

    Thanks.

    liam.

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Hey,

    You can use the ProcessStartInfo class:

    http://msdn.microsoft.com/en-us/libr...roperties.aspx

    To specify the properties that you want to assign to the process that you are trying to start.

    What exactly is this batch file doing? Can you work not be done within your own application?

    Gary

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey,

    What it's actually doing is launching a dedciated server [.bat], inside my hosting app i am making for a freeware software peice. If i you could put it in it i wouldn't know as i have only started vb recently after years of php and html.

    Thankyou.
    Liam

  8. #8
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Linking to files.

    Quote Originally Posted by Hack View Post
    vb.net Code:
    1. System.Diagnostics.Process.Start("c:\myfile.htm")
    Change the path and file name to suite your needs.

    Will this open the specified HTML file in the users default browser? That seems like the obvious answer.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  9. #9
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Hey,

    So essentially, you want to fire up this bat file, as a process, and have it run indefinitely, is that it?

    Gary

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hello,

    Well however long the user wants to run a server ;x i just want the app to open be able to start the .bat file .. lol
    Obvoiusly if they want it indeffinately , then yes.

    il try them links you gave .

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Sounds like a plan.

    You might also want to take a look here:

    http://support.microsoft.com/kb/305369

    Gary

  12. #12
    Banned
    Join Date
    Jul 2010
    Location
    china
    Posts
    1

    Re: Linking to files.

    is it a plan Using Visual Studio 2008 to Assemble, Link, Debug, ... Create intermediary batch file(s) to be called by VS to then invoke the proper .
    Last edited by si_the_geek; Jul 21st, 2010 at 04:28 AM. Reason: removed advertising link

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hi cikoo,

    nono i have already made the bat file i just want to be able to goto menu and click start and that executes the .bat file to start.. Still no look ;s .

    had a look on microsoft site but i tried filename the one which seemed would do the job but abit of a problem..

    vb Code:
    1. Namespace MyProcessSample
    2.  
    3.         Class MyProcess
    4.  
    5.             Public Shared Sub Main()
    6.                 Dim myProcess As New Process()
    7.  
    8.                 Try            
    9.  
    10.                     myProcess.StartInfo.UseShellExecute = False
    11.                     myProcess.StartInfo.FileName = "C:\Program Files (x86)\Dedicated Server Cient\Server1.bat"
    12.                     myProcess.StartInfo.CreateNoWindow = True
    13.                     myProcess.Start()
    14.                    
    15.                      Catch e As Exception
    16.                     Console.WriteLine((e.Message))
    17.                 End Try
    18.             End Sub 'Main
    19.         End Class
    20.     End Namespace

    It only turns the bat on then closes it down so i see the cmd pop up then disapear i think the vb is opening it then shutting it down..

  14. #14
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Hey,

    Did you read the link that I posted?

    There is a section titled:

    Wait indefinitely for the shelled application to finish

    and:

    Provide a time-out for the shelled application

    If after using either of those, you are still not getting what you want, then it must be the bat file itself that has the problem.

    Gary

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hello,

    Oh sorry garry, i didn't notice them.. lol

    liam.

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    This is going to sound very noobie, okay this is code alot of errors when i start to debug it. I'm knew to this vb thing so don't expect me too know alot lol. Do i just put this in like this ?
    vb Code:
    1. string sysFolder=
    2.     Environment.GetFolderPath(C:\Program Files (x86)\Server client\server1.bat);
    3.     ProcessStartInfo pInfo = new ProcessStartInfo();
    4.     pInfo.FileName = sysFolder + serevr1-cmd.txt";
    5.     Process p = Process.Start(pInfo);
    6.     p.WaitForInputIdle();
    7.     p.WaitForExit();
    8.     MessageBox.Show("Code continuing...");

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    That code is C#, not VB.Net.

    The equivalent in VB.Net would be something like:

    Code:
    Dim sysFolder As String = Environment.GetFolderPath("C:\Program Files (x86)\Server client\server1.bat")
    Dim pInfo As New ProcessStartInfo()
    pInfo.FileName = sysFolder & "serevr1-cmd.txt"
    Dim p As Process = Process.Start(pInfo)
    p.WaitForInputIdle()
    p.WaitForExit()
    MessageBox.Show("Code continuning...")
    Hope that helps!!

    Gary

  18. #18

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey gary ,

    seemed to work until this :

    ill try and have a look if ic an rectify this hmm..

    Sorry for about nagging you mate.

    Reagrds, liam.

  19. #19
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Can you set a breakpoint in your code?

    What line of your code is throwing the exception?

    Gary

  20. #20

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey ,
    Dim sysFolder As String = Environment.GetFolderPath("C:\Program Files (x86)\Nightfire Dedicated Server\server1.bat")

    Your help is much apprecaited .

    liam.

  21. #21

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Bumpety bump

  22. #22

  23. #23
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Ah, good point, I didn't catch that when I was converting, I just did a blind convert.

    What you would need then is just:

    Code:
    Dim sysFolder As String = "C:\Program Files (x86)\Server client\server1.bat"
    Dim pInfo As New ProcessStartInfo()
    pInfo.FileName = sysFolder & " serevr1-cmd.txt"
    Dim p As Process = Process.Start(pInfo)
    p.WaitForInputIdle()
    p.WaitForExit()
    MessageBox.Show("Code continuning...")
    And, assuming that serevr1-cmd.txt is an input argument to the bat file, notice I have added an extra space.

    Gary

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey thankyou you too ,

    Code:
    Dim sysFolder As String = "C:\Program Files (x86)\Server client\server1.bat"
            Dim pInfo As New ProcessStartInfo()
            pInfo.FileName = sysFolder & " serevr1-cmd.txt"
            Dim p As Process = Process.Start("C:\Program Files (x86)\Server client\server1.bat")
            p.WaitForInputIdle()
            p.WaitForExit()
            MessageBox.Show("Code continuning...")
    however this pops up
    WaitForInputIdle failed. This could be because the process does not have a graphical interface.
    pointing at the
    Code:
       p.WaitForInputIdle()
            p.WaitForExit()
    lines.

    Sorry to cause mayhem ;p , i will have a look at microsoft website.. When i tried pinfo it said it couldnt find file..
    Last edited by mafia; Jul 22nd, 2010 at 09:11 AM.

  25. #25
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Actually, yes, that isn't going to work.

    You are going to need to do this:

    Code:
    pInfo.FileName = sysFolder
    And then:

    Code:
    pInfo.Arguments = "serevr1-cmd.txt"
    As per documentation here:

    http://msdn.microsoft.com/en-us/libr...arguments.aspx

    Gary

  26. #26

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Still got same bug ;s , would it be easier if i sent you the stuff too see through ;x .. I really do appreciate your time.. and admire your willingness to help.

    Ill see if ic an try to convert .bat to another format..

  27. #27
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Sure, you can upload a test project, and I will see if I can take a look at it.

    Gary

  28. #28
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Okay, it is going to be difficult for me to test this for you, as there are a lot of dependencies in the files that you are using, namely, files that I don't have on my machine.

    What you have looks good though.

    What happens if you take out the WaitForInputIdle() call. Does it work then?

    Gary

  29. #29

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey ,

    it opens it but then about 5 secs after launching shuts it down ;s.

    Thankyou for your help.

    Regards,

    liam.

    Shall i send you the bat ;s ?

  30. #30
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    In order to test, it would require more than just the bat file, it would need the exe that you are running as well, which likely has lots of dependencies on it. Also, no disrespect, but I am not going to fire up a random exe on my machine, plus it is likely to break all sorts of licensing rules.

    If you start the exe up manually, I take it it just runs continually?

  31. #31

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Yeah when the bat is run manually it works just fine... I think im going to ahve to try and convert this file too another format..

    Regards, liam.

  32. #32
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    When you say you "run" the batch file, do you mean you just double click the bat file, or do you pass it as a parameter into the exe using the command line?

    Gary

  33. #33

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Double click ;s

  34. #34
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Ok, so your batch file must internally be calling the exe that you want to run. That is not what your code is doing.

    You code is running up the exe, passing in the batch file as a parameter.

    Change your code to do a Process.Start directly on the batch file.

    Gary

  35. #35

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hi , have been out of town.

    Ill try adding this. thanks.

  36. #36
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    Not a problem at all.

    Post back once you have had a chance to play, and we will try and get this working for you.

    Gary

  37. #37

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hi i think i have found code..
    Code:
    Dim psi As New ProcessStartInfo(paths.serverclientDir & "\Server" & ServerID + 1 & ".bat")
            psi.WorkingDirectory = Paths.serverclientDir
            Process.Start(psi)
    What would i put as the patch is that like C://..

  38. #38

  39. #39
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Linking to files.

    You could also provide the user with the ability to select the file that they want to use, using an OpenFileDialog.

    Gary

  40. #40

    Thread Starter
    Junior Member
    Join Date
    Jul 2010
    Posts
    22

    Re: Linking to files.

    Hey im kinda confused..
    Code:
            Dim psi As New ProcessStartInfo(paths.NFBuddyDir & "\Server" & ServerID + 1 & ".bat")
            psi.WorkingDirectory = paths.NFBuddyDir
            Process.Start(psi)
    Hmm , iw ant it to go to the C:\\programfiles(x86)\NFBuddy file.. I tried the things for the path but was very confused. Sorry.

Page 1 of 2 12 LastLast

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