C# - Check For Changes In A File Launched With Process.start()

May 22, 2012

I'm developing a vbnet/c#.NET based application that opens files with different applications(excel, word, etc).

The application is launched using Dim app As Process = Process.Start(ProcessProperties)

Now, when I have to terminate the process I use app.Kill() but I need to check if the document has been modified before killing it.

How can I handle that? And if it's possible, how can I launch the application native prompt for save?

View 3 Replies


ADVERTISEMENT

.net - Process Launched From Service Can't Run Word Mail Merge In Win7?

Oct 5, 2010

In Win7, I am running a service which launches a process which hosts the office-library (Word 2007) for the purpose doing a mail-merge. There is no interface anywhere. When I launch the mail-merge process with the service as the parent, Word cannot create a document using my existing mail-merge Word doc. At first I thought the problem was with UAC so I changed the manifest to run as admin but it seems like that was irrelevant. When I launch the process from explorer or a non-service process instead of the service it works and is able to load Word and a document successfully. I used Process Monitor to see if I could get some clues as to what could be happening. As far as I can tell, when the proc is launched by the service it is using system profile since I see file paths such as c:windowssystem32configsystemprofile and c:windows mp instead of my user profile folders C:UsersUserNameAppDataRoamingApplication etc. My service is running as my username and not localsystem. I check the username using WindowsIdentity.GetCurrent().Name and I get my correct username regardless of service/non-service invocation. I tried changing the Word startup path in the Application object but again it only succeeds in non-service mode. I tried creating the process from the service in both shell mode and non-shell mode and they both behave similarly. I think the problem could lie in the fact that when the proc is launched by the service the user belongs to NT Authority/Service but when launched any other way it is NT

View 1 Replies

Check If Program Was Launched At System Startup?

Feb 29, 2012

I have set my program up to run on system startup like so:

Code:
Private Sub enableRunOnSystemStartup()
My.Computer.Registry.CurrentUser.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun", True).SetValue(Application.ProductName, Application.ExecutablePath)
End Sub

The problem is that when it does start, it opens up in a window. I wish to provide the user with 4 options for what to do on system startup.

1. Don't run on system start.
2. Run and open a window.
3. Run but start minimized to the taskbar.
4. Run but start minimized to the system tray.

It's options 3 and 4 that cause the problem. If the user starts the program manually, it should start in window mode, but if the program starts from system startup, I need to check which option the user has selected and perform that option.

I was thinking of passing some sort of parameters to the program when it loads but I am not sure how these parameters could be sent to the program. One way would be to create a separate program that loads on system startup. When that program loads, tell it to load my program but pass a parameter to it to tell it that it was booted from startup. I feel like there should be a better way.

I was also thinking of getting the time of the last system bootup. Then comparing it with the current time, although this might not work if the user loaded my program as soon as they logged on.

A third idea I came up with was to use a shortcut to the exe file and check if the program was executed using that shortcut. I could place the shortcut in the folder ...AppDataRoamingMicrosoftWindowsStart MenuProgramsStartup as opposed to adding it to the registry. But would this work on other Windows operating systems? I'm using Windows 7.

Ideally, this program should be able to run on other computers, but if that is too complicated, I'd rather just get it running on mine first.

Also, in case anyone is interested, my program creates a copy of the user's files on a separate drive, although I don't think this affects what I am trying to do with checking if my program was launched at system startup.

View 8 Replies

Cannot Start Process Because A File Name Has Not Been Provided

Jul 14, 2008

When I ran the application, I am getting error as Cannot start process because a file name has not been provided. [code]

View 3 Replies

File Not Found On Process.start()?

Jul 7, 2011

its really simple...
Dim myProcess As New Process()
Try

[code].....

View 1 Replies

Delete A File After Process.Start Runs?

Feb 22, 2012

I'm creating a sub that will run a batch file, and then delete it when it has finished.[code]...

This causes the program to immediately delete the batch file before it can run. How can I break it up so that it won't delete the batch file until after it has finished?

View 2 Replies

Process.Start - Reference To The Local File

May 16, 2012

I have an application that that uses process.start. It works fine on my development machine...but not on an installed machine....at least not for a local file. The following illustrates my problem...the reference to the url works fine and every time. However, the reference to the local file may work the First time but on any following attempts will close the application with a WindowsApplication1 error. Since it can find the file occasionally it is not a file problem.

[Code]....

View 17 Replies

Process.start And Redirect Output To File?

Jan 15, 2011

I want to launch a file from a VB program and capture the output of that file in a text document.Here's an example:Process.Start("systeminfo.exe > Data.dat")This doesn't work. I get an error that the file cannot be found. I've tried using Shell instead of Process.Start. I've also tried replacing systeminfo.exe with a variable and replacing the redirect portion with a variable.The ultimate goal is to get the text file e-mailed. So, if it were possible to output to the Clipboard, then paste that to a file or directly into an e-mail client that would also work.

View 1 Replies

System.Diagnostics.Process.Start When File Is Not Associated?

Nov 30, 2009

I'm using System.Diagnostics.Process.Start to open a file using a string stored in a SQL datatable. It works absolutely fine as long as there is an application on the local machine associated with the file type. If there isn't an association, what happens is the "Save as" dialog box pops up. What I'd like to happen is to just bring up a message box or some other prompt that tells the user what the problem is, and to contact the helpdesk. Some users will be confused if they see a "Save as" dialog box, I think.

View 2 Replies

VS 2008 - How To Open File Using Process.Start

Jul 8, 2009

I'm trying to open any file using Process.Start, but every time I try to open a file that isn't an executable the program crashes... This is the code I'm currently using:

vb.net
Private Sub ListView1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDoubleClick
For Each lvi As ListViewItem In ListView1.SelectedItems
Process.Start(path & "" & lvi.Text)
Next
End Sub

Path is a string that contains the selected folder path, and lvi is the text of the list view item (each item contains the icon and name of each file). It is working fine for .exe files, I was just wondering if it's JUST for .exe files...

View 15 Replies

VS 2010 File Not Found On Process.start()?

Jul 7, 2011

its really simple...

Dim myProcess As New Process()
Try
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "C:windowssystem32wuauclt.exe"
myProcess.Start()

[Code]...

View 10 Replies

C# - Process.Start Dirquota.exe - The System Cannot Find The File Specified

Sep 9, 2010

I am using a System.Diagnostics.Process to execute dirquota.exe. I catch an exception at .Start() which is "The system cannot find the file specified".

I am now doing:

foreach (var fi in new DirectoryInfo(@"C:WindowsSystem32").GetFiles())
{
Console.WriteLine(fi.Name);
}

This outputs pretty much every file in that directory apart from dirquota.exe.

View 2 Replies

Forms :: Use Process.start Based On Settings File?

May 14, 2010

My first post! im quite new to programming but loving every minute of it.Basically i want to open another exe file from vb.net 2010. i can do it normally using

system.Diagnostics.Process.Start _ ("c:winamp.exe") if winamp for example is installed on another pc in another location i want to run it from my program but i want there to be sort of like a settings.txt file where you can edit the path to winamp and my program should first read the path set in the settings file and then open accordingly. how do i go about doing this?

btw it would be great if you could point me in the right direction for making a windows form where one can edit the settings file within my program without editing the settings file in notepad

View 4 Replies

VS 2008 - Process.Start() - Inconsistent - Load A File On Network

Oct 22, 2009

Im simply trying to load a file on my network. The file is a database file for access.. This code opens the file on my computer. However on the four computers tested 2 of them throw an error stating that the user canceled the operation. However the user didn't do anything. The error is thrown automatically. The other two are working perfectly fine.

[Code]...

View 2 Replies

Process.start() Providing Different Results When Running A Batch File Than When It Is Manually Run ... Win 7 X64

Feb 11, 2011

I'm having different results when running openfiles.exe manually than when I run it with Process.start() Below is the portion of code making the call. I have read in several places that using the "runas" verb might make a difference since I am running on Win 7 x64, however I am still experiencing different results.

[Code]...

View 1 Replies

Process.Start To Start An External Command Line Application

Aug 4, 2009

I'm using Process.Start to start an external command line application and using the StartInfo.Arguments method to send parameters to the application. I imagine I'll need to use a loop... but I can't figure out exactly how yet.I need to send anywhere from 1 - an infinite number of files names to this application. Each file has to be sent one after the other. So once the first one is done, I need to loop back around and past the second one.I can probably use the Directory.GetFiles method to get all of the files, but I don't know how to assign them.

View 7 Replies

Use Process.Start To Start An Application Without Administrator Privileges On Windows 7

Feb 24, 2012

Visual Basic 2010 - Net Framework 4.0 Client

I have an application (application #1) running with Administrator privileges on Windows 7.

I want application # 1 to start another application (application #2) without Administrator privileges so application #2 is running as a standard user.

Is there a way to do this? I have been using Process.Start.

View 5 Replies

VS 2010 Unable To Start Specific Command With Process.start

Jun 18, 2011

Here's what I currently have:

[Code]...

I've commented out various things to limit it to specifically this command (example, I can swap mklink out with notepad and it works fine). The command runs fine from a DOS window, but can't be found when I use it this way. I also tried using the SHELL command just to test and I get the same results. No idea why it can't be found, as like I said it executes from the command prompt just fine.

View 2 Replies

Delete Exe File That Launched My Program?

Mar 27, 2010

Is it possible to delete the exe file that launched my program

View 3 Replies

Check A File Which Want To Delete Is Not More Used By Another Process?

Jan 8, 2012

how to check a file which i want to delete is not more used by another process?I have a program it creates a temp file less than 1KBthen it sends it like an attachment in the emailthen I have to delete it,but cannot do it because exception comes out that it still used by another process

Try
Dim AnEmailMessage As New MailMessage
AnEmailMessage.From = New MailAddress("bla@bla.com")

[code].....

View 6 Replies

Check If File Is Open Or Used By Another Process

Aug 12, 2009

I have a filesystemwatcher that watches a certain folder.. Now i use system.thread.sleep to be sure that the file is completely copied to the folder that i watch..But this is not a good way!i know there is a way to check if the file is open or used by another process, but i dont know the code.[code]

View 2 Replies

Check When File Is Open Or Used By Another Process?

Aug 13, 2009

I have a filesystemwatcher that watches a certain folder.. Now i use system.thread.sleep to be sure that the file is completely copied to the folder that i watch..[code]....

View 10 Replies

VS 2010 : Check If A File Is Being Used By Another Process?

Sep 30, 2011

The only logical way is reading the file and creating Try and Catch?

View 4 Replies

OSK Process Start/stop - PID.Kill() Fails Because It Says The Process Already Exited

Sep 28, 2010

My app starts an On-Screen Keyboard process like this:

Dim PID as System.Diagnostics.Process
:
PID = Process.Start("C:WindowsSystem32osk.exe")
:

[CODE]...

It seems to work 90% of the time. However, sometimes the PID.Kill() fails because it says the process already exited. At this point the OSK is always still there on screen. Yes, I know my code should be testing to see if the process is still running before trying to kill it, but given that the OSK is still on screen..

View 10 Replies

Process.start() Freezes Main Program Until Process Finishes?

Feb 21, 2011

I have a program that starts another program after setting the regkeys basically the program continually syncs the calandar of outlook and another application.I set the regkeys than launch the c:sync.exe app. I have tried a simple process.start and launching the process as a thread and they both do the same thing: The other process starts and works as it should but my main program goes "White screen" or "not responding" until the process.start has exited.

I want the process.start to run in the background so if users click in my main app it responds and truly that they can access the context menu of my main app from the taskbar while the process.start is running.

View 5 Replies

VS 2008 If Process Is Running Give Focus, If Not Start Process?

May 27, 2010

Trying to create a button that when clicked will check to see if a certain process image is running and if that process is running give the process focus. If the process is not running then start the application.

View 9 Replies

VS 2008 Process.Start Error Starting Process?

Aug 8, 2010

Whats happening is I run the code below and get the following error "The system cannot find the file specified". I've read that with UseShellExecute set to false that you can't use WorkingDirectory.

Dim Password As String = "password"
Dim SecureStringPassword As New System.Security.SecureString
For Each c As Char In Password

[Code].....

View 8 Replies

Filesystemwatcher - Check If File Is Open Or Used By Another Process?

Aug 10, 2009

I have a filesystemwatcher that watches a certain folder.. Now i use system.thread.sleep to be sure that the file is completely copied to the folder that i watch..But this is not a good way!

I know there is a way to check if the file is open or used by another process, but i dont know the code..

[Code]....

View 3 Replies

C# - Start New Process, Without Being A Child Of The Spawning Process

Dec 8, 2011

How would I go about starting a new process without it being the child of the calling process.

Example:

Main Program (Caller.exe)
process.start("file.exe")

View 3 Replies

Use System.Diagnostics.Process.Start To Run A Process?

Jun 24, 2009

i use System.Diagnostics.Process.Start to run a process

example :

Dim p As New System.Diagnostics.Process
p = System.Diagnostics.Process.Start("D:ProjectApplication.exe")

it works perfectly during run time. but after i deploy to server.... this code did nothing, it did not call out this process

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved