|
-
Jul 20th, 2010, 08:54 AM
#1
Thread Starter
Junior Member
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.
-
Jul 20th, 2010, 11:09 AM
#2
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.
-
Jul 20th, 2010, 01:08 PM
#3
Thread Starter
Junior Member
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.
-
Jul 20th, 2010, 01:12 PM
#4
Re: Linking to files.
vb.net Code:
System.Diagnostics.Process.Start("c:\myfile.htm")
Change the path and file name to suite your needs.
-
Jul 20th, 2010, 02:56 PM
#5
Thread Starter
Junior Member
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.
-
Jul 20th, 2010, 03:30 PM
#6
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
-
Jul 20th, 2010, 04:06 PM
#7
Thread Starter
Junior Member
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
-
Jul 20th, 2010, 08:26 PM
#8
Hyperactive Member
Re: Linking to files.
 Originally Posted by Hack
vb.net Code:
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.
-
Jul 21st, 2010, 01:00 AM
#9
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
-
Jul 21st, 2010, 02:03 AM
#10
Thread Starter
Junior Member
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 .
-
Jul 21st, 2010, 02:11 AM
#11
Re: Linking to files.
Sounds like a plan.
You might also want to take a look here:
http://support.microsoft.com/kb/305369
Gary
-
Jul 21st, 2010, 02:29 AM
#12
Banned
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
-
Jul 21st, 2010, 02:48 AM
#13
Thread Starter
Junior Member
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:
Namespace MyProcessSample
Class MyProcess
Public Shared Sub Main()
Dim myProcess As New Process()
Try
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "C:\Program Files (x86)\Dedicated Server Cient\Server1.bat"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Exception
Console.WriteLine((e.Message))
End Try
End Sub 'Main
End Class
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..
-
Jul 21st, 2010, 03:01 AM
#14
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
-
Jul 21st, 2010, 03:36 AM
#15
Thread Starter
Junior Member
Re: Linking to files.
Hello,
Oh sorry garry, i didn't notice them.. lol
liam.
-
Jul 21st, 2010, 03:45 AM
#16
Thread Starter
Junior Member
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:
string sysFolder=
Environment.GetFolderPath(C:\Program Files (x86)\Server client\server1.bat);
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.FileName = sysFolder + serevr1-cmd.txt";
Process p = Process.Start(pInfo);
p.WaitForInputIdle();
p.WaitForExit();
MessageBox.Show("Code continuing...");
-
Jul 21st, 2010, 04:07 AM
#17
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
-
Jul 21st, 2010, 05:18 AM
#18
Thread Starter
Junior Member
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.
-
Jul 21st, 2010, 05:33 AM
#19
Re: Linking to files.
Can you set a breakpoint in your code?
What line of your code is throwing the exception?
Gary
-
Jul 21st, 2010, 05:54 AM
#20
Thread Starter
Junior Member
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.
-
Jul 22nd, 2010, 03:46 AM
#21
Thread Starter
Junior Member
-
Jul 22nd, 2010, 03:49 AM
#22
Re: Linking to files.
GetFolderPath
Gets the path to the system special folder that is identified by the specified enumeration.
System.Environment.SpecialFolder enumeration
-
Jul 22nd, 2010, 04:05 AM
#23
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
-
Jul 22nd, 2010, 09:08 AM
#24
Thread Starter
Junior Member
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.
-
Jul 22nd, 2010, 09:16 AM
#25
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
-
Jul 22nd, 2010, 11:09 AM
#26
Thread Starter
Junior Member
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..
-
Jul 22nd, 2010, 11:36 AM
#27
Re: Linking to files.
Sure, you can upload a test project, and I will see if I can take a look at it.
Gary
-
Jul 23rd, 2010, 03:46 PM
#28
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
-
Jul 23rd, 2010, 04:01 PM
#29
Thread Starter
Junior Member
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 ?
-
Jul 23rd, 2010, 04:05 PM
#30
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?
-
Jul 24th, 2010, 02:25 AM
#31
Thread Starter
Junior Member
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.
-
Jul 24th, 2010, 03:05 AM
#32
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
-
Jul 24th, 2010, 03:06 AM
#33
Thread Starter
Junior Member
-
Jul 24th, 2010, 03:49 AM
#34
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
-
Jul 25th, 2010, 04:30 AM
#35
Thread Starter
Junior Member
Re: Linking to files.
Hi , have been out of town.
Ill try adding this. thanks.
-
Jul 25th, 2010, 03:24 PM
#36
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
-
Jul 26th, 2010, 02:31 AM
#37
Thread Starter
Junior Member
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://..
-
Jul 26th, 2010, 02:40 AM
#38
Re: Linking to files.
Either it should be:
Code:
\\Computername\SharePath
or simply:
Code:
C:\Folder\Subfolder\Filename.ext
-
Jul 26th, 2010, 02:45 AM
#39
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
-
Jul 28th, 2010, 10:40 AM
#40
Thread Starter
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|