|
Hi to All
I have a few doubts on creation of process to execute any exe/ppt/any file in VB.NET. Please clarify me
1) How to use waitforexit() methods. Its not working for me in some cases?
My code is..
dim p as new process
p.startInfo.filename=MyPath
p.start()
p.waitforexit()
Sometimes If I run a calc, (ie MyPath is either calc.exe or a path to a shortcut of calc)..It runs the calc and shows an error in p.waitforexit() saying something like "p has not assign any process"
2)Can we check for an process if it is alive? I want to check if explorer.exe is running?
3)Can we maximise and bring it to front of the all window, for a process which is running? (eg: I have a form which covers the desktop. I have a button(run calc) which runs calculator..Now after running if I click on the form,the calc goes back to my form...Now if I click the button(run calc),I dont want to open a new calc,...instead I want to bring the already running calc on top.)
Thnaks in advance
-----------------------------
I am a beginner
|
|
|
|
|
p.startInfo.filename=MyPath
p.start()
If (!p.HasExited && p.Responding) Then
p.waitforexit()
End If
himangshuS wrote: 2)Can we check for an process if it is alive?
Yes. Check out the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.hasexited.aspx">HasExited</a>[<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.hasexited.aspx" target="_blank" title="New Window">^</a>] and the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.responding.aspx">Responding</a>[<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.responding.aspx" target="_blank" title="New Window">^</a>] properties.
himangshuS wrote: 3)Can we maximise and bring it to front of the all window, for a process which is running?
Yes. You'll have to get the handle to the mainform, based on the proces-id. Then you can set the WindowState and you can BringToFront the Window
I are troll
|
|
|
|
|
thnaks for your reply..
About my first doubt,...fine I will execute your code and see. But Could you please tell me what could be the problem in the line p.waitforexit()...that happen only sometimes,spexially when I run calc.
About my second problem:: How do I check for the process explorer.exe? Could u please a sample code, Since I will have to get the process id for explorer.exe or something like that?
For the third one...Are you talking about the handle of my application window or the proicess window ie calc?...Also How will I get to know the exact process Id?..since if I can run calc more then one time...how will i get process id for each one?
thanks
-----------------------------
I am a beginner
|
|
|
|
|
himangshuS wrote: About my first doubt,...fine I will execute your code and see. But Could you please tell me what could be the problem in the line p.waitforexit()...that happen only sometimes,spexially when I run calc.
It may already have been terminated, or just too busy to proces incoming messages.
himangshuS wrote: About my second problem:: How do I check for the process explorer.exe? Could u please a sample code, Since I will have to get the process id for explorer.exe or something like that?
Use the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx">Process</a>[<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx" target="_blank" title="New Window">^</a>] class to get a list of all running processes.
' Start Explorer.
Dim p As Process
p = Process.Start("explorer.exe")
MessageBox.Show(p.Id)
himangshuS wrote: since if I can run calc more then one time...how will i get process id for each one?
Well, you get an Id each time you start "calc.exe" through the Process class. Your best option would be to keep a list around of the processes that you started. I wouldn't close any of the processes that you didn't start yourself; the end-user might be really confused if his/hers calculator suddenly dissapears.
I are troll
|
|
|
|
|
You're calling WaitForExit before the process even has a chance to start. Starting a new process is a very expensive call. The Start method does not wait for the process to completely start before returning.
It's up to you to wait for the app to start, by calling p.WaitForInputIdle before you call the WaitForExit method.
himangshuS wrote: Now if I click the button(run calc),I dont want to open a new calc,...instead I want to bring the already running calc on top.)
Then you have to check to see if it's still running (the user may have closed it), relaunch it if needed, easily done using the Process class. If it's still running, then you can get the ProcessId from its Process object, than pass that to AppActivate to bring it to the front.
|
|
|
|
|
thanks
Could you please help me with the code since I have very less idea about the process class an all.
In order to maximise or bring the already running calc/any process to front
thanks
-----------------------------
I am a beginner
|
|
|
|
|
I'm not writing your code for you.
Check out the Process.GetProcessesByName method.
|
|
|
|
|
Dear all
i have this problem keeps coming often using inet control 12002 time out
can any body give me the solution .its very urgent...
i am using the inet control to download the data from remote server..
the main intention is to download the database rows from remote server to my local system which is in access database
plzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me
thanks in advance
|
|
|
|
|
Are you saying that you're trying to use an Access database on a remtoe machine, acrossed the Internet?? Since Access is a file based database, this is a very high security risk!
|
|
|
|
|
To add to Dave K's point. I have used Access over a company intranet and found the performance pretty poor even with dedicated links. Over the internet I'd think it's a non-starter.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
how to create codeing for search files in computer for using language for vb.net.
|
|
|
|
|
Simple:
Install visual studio
Create new project
Start coding.
More serious answer:
Look at the system.io namespace
system.io.file
system.io.directory
system.io.path
Without more information nobody can truly give you an answer.
|
|
|
|
|
Hi,
I would like to know if there is a possible way to set the folder name as the newly created file name??
I have a folder which contains n number of files.
I have appened all those files as single a new file.
Now I want to name that file with the name of the folder.
Any means to do it?
Thanks in advance
|
|
|
|
|
Check out FileInfo.Directory property. Might help you.
जय हिंद
|
|
|
|
|
Have you tried just creating the file with the same name as the folder in your program?
E.g. if input folder is C:\myStuff\myTextfiles\ then output file is C:\myStuff\myTextfiles i.e. no trailing \.
Don't know if it will work but worth a shot.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Hi David,
My input folder is got from the FolderBrowserDialog.
The input folder path is not hardcoded.
In that case how to manage?
|
|
|
|
|
Use SelectedPath property and extract string after last "\".
जय हिंद
|
|
|
|
|
In that case just try using the SelectedPath from the FBD for both input path and output file - IIRC FolderBrowserDialog returns path without the trailing \.
As I said don't know if it will work, but don't see why not (you can have a file and folder with same name in Windows).
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
I think this piece of code might help:
Dim test As String
'This will get the Folder name from the selected path.
test = FileIO.FileSystem.GetName(FolderBrowserDialog1.SelectedPath)
'So if you had a folder path of C:\Program Files\SomeFolder\Program1 selected the above command should 'display Program1
I hope this helps.
|
|
|
|
|
Hi all,
Is it possible to create our own FolderBrowserDialog???
I have created my own MsgBox.
Code:
Sub MyMessageBox1(ByVal strMessage As String, ByVal imgImage As Image)
Dim frmMsgBx As New Form
Dim pbxMsgImage As New PictureBox
Dim lblMsgText As New Label
Dim btnMsgOK As New Button
With frmMsgBx
.MinimizeBox = False
.MaximizeBox = False
.Width = 50
.Height = 20
.AutoSize = True
.BackColor = Color.MediumAquamarine
.Text = "Saved"
.StartPosition = FormStartPosition.CenterScreen
End With
With pbxMsgImage
.Parent = frmMsgBx
.Left = 12
.Top = 12
.Width = 50
.Height = 50
.Image = imgImage
.SizeMode = PictureBoxSizeMode.StretchImage
End With
With lblMsgText
.Parent = frmMsgBx
.Left = 100
.Top = 20
.Width = 300
.Height = 20
.Text = strMessage
.TextAlign = ContentAlignment.MiddleCenter
End With
With btnMsgOK
.Parent = frmMsgBx
.Left = 175
.Top = 45
.Width = 75
.Height = 23
.Text = "OK"
.DialogResult = DialogResult.OK
BackColor = Color.MediumAquamarine
End With
frmMsgBx.ShowDialog()
Button3.Enabled = False
End Sub
/pre>
In the same way is it possible to create a new FolderBrowserDialog???
Thanks in advance
|
|
|
|
|
Yes, you can create your own folder browser dialog.
जय हिंद
|
|
|
|
|
Within a VB6 form frmMain with a button that have the following click sub
Dim Ace As Object
Set Ace = CreateObject("Access.Application")
Ace.OpenCurrentDatabase "c:\test.mdb", False
Set Ace = Nothing
unload frmMain
The test.mdb opens perfectly but it is not full screen. How can i open it with full screen?
Thanks in anticipation.
|
|
|
|
|
Try this ...
' Maximize the Access window:
oAccess.RunCommand(Command:=Access.AcCommand.acCmdAppMaximize)
I got it from the following article:
How To Automate Microsoft Access From Visual Basic .NET
http://support.microsoft.com/kb/317113[^]
|
|
|
|
|
Thanks mate
it works with a slight changed for VB6 ie
oAce.RunCommand acCmdAppMaximize
Cheers!
|
|
|
|
|
Hi Everybody,
My question is regarding using the LZO.NET library in a VB.NET project.
The code below is a small class "tester" which decompresses a Byte().
The problem is that the function is returning only ""
What is it that I could be doing wrong?
Abhay
===========================================================================================
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Imports System.Net
Imports System.Threading
Public Class Tester
'Here bteReceiveData is a Array of Bytes that are compressed using LZO.
Public Function Decompress(bteReceiveData() As byte) As String
oLzo = New Simplicit.Net.Lzo.LZOCompressor()
Dim cDecompressed As String
cDecompressed = Encoding.Unicode.GetString(oLzo.Decompress(bteReceived))
return cDecompressed
End Function
End Class
===========================================================================================
Abhay
StanSoft
|
|
|
|