|
So I am able to successfully enumerate the processes on a machine using the remote machine's name on the network such as:
Process[] myProcesses = Process.GetProcesses("Machine_Name_Here");
However, I'd like to also use myProcesses[0].Kill() for example to kill the process and then after use something like Process.Start("blah") to start it again.
The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Is there anything I can do for this desired functionality?
|
|
|
|
|
InvalidTypecast wrote: The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Neither is starting a remote process, for the obvious security implications.
You can start a NON-INTERACTIVE process remotely using the WMI Win32_Process class. But, again, the user will NOT see any indication that the process is running. It will not be allowed to put up ANY user interface at all.
|
|
|
|
|
Yes, these are just command line applications with no interactivity that I need to restart essentially. Do you know of an article that provides a noobie example on using WMI for this?
|
|
|
|
|
|
Not specifically for the Win32_Process class, but if you Google "C# WMI invoke method", you'll get something like this[^]. You can find the docs on the Win32_Process class here[^]. You're looking for the Create and Terminate methods.
|
|
|
|
|
Hello All,
Greetings!
My task is to retrieve the Date Taken field of images in a folder. Here is the code I have used
//For each file in the folder
void Srch_DT(FileInfo f, string condition,string value)
{
Image img = null;
PropertyItem pi = null;
try
{
img = Image.FromFile(f.DirectoryName + @"\" + f.Name);
pi = img.GetPropertyItem(36867);//Retrieve DateTaken
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
//Something else
}
As I see, if the number of images in the folder is large, I encounter this exception:
" A generic error occurred in GDI+."
What should be done to take care of this error?
Appreciate any help!
Thanks
D
|
|
|
|
|
Hi,
you should call img.Dispose() as soon as you no longer need the image,
so its unmanaged resources don't get lost.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
Thanks for that!
However I see the error even I after I use the img.Dispose().
Also it displays Not responding in the title. I am running this on Vista Home Basic.
D
-- modified at 15:01 Monday 22nd October, 2007
|
|
|
|
|
OK,
the problem is GDI+ has only a single error message, the one you are getting;
the next most probable cause is a bad image file, so make sure you see the filename
that is current when the exception occurs (best is to show Exception.ToString, not
just Exception.Message).
Then try if you can open just that one file, my best guess is you won't succeed;
delete (move away) that one file, and try again.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Bingo! Yes there were few corrupted images. It would be ok to by-pass these images.
However one last question..
After the application starts running. it shows Not responding in the title. How could I deal with this? Will this be an performance issue?
Thanks again for the solution!
D
|
|
|
|
|
Hi,
you're welcome.
I'm guessing you are doing all the image stuff on the main thread, which should be
free to keep the GUI alive. Two solutions, assuming your image stuff starts with the
click of a button:
1.
The official solution is to use a separate thread, which you would create and start
in the button click handler;
if you do, you would need Control.InvokeRequired and Control.Invoke() to access Controls
e.g. to show the exposure date (read up on these).
2.
A hack might do it: you can include Application.DoEvents() say once per image, provided
you make sure no recursion can occur, that is, you should disable that button for
as long as it is processing your images.
But 1. is definitely the better approach.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks Luc!
I have never worked with the thread stuff! Guess its time I get started on this.
Thanks again! U made my day!
D
|
|
|
|
|
Hi,
I am having some problems to use enqueue/dequeue classes.
private void btnSend_Click(object sender, System.EventArgs e)
{
for (int i = 0; i < chckListBox.Items.Count; i++)
{
if (chckListBox.CheckedIndices.Contains(i))
{
string tmpItem = chckListBox.Items[i].ToString();
//parse the string Names and Phone Numbers
string[] info = tmpItem.Split (',');
myQueue.Enqueue(info[0]);
while (myQueue.Count != 0)
{
myQueue.Dequeue();
}
}
}
}
I want to make use the values in dequeue in another mehtod, i want to send the each value of the queueue to a method, or want to sign it smthn else How can I do that?
|
|
|
|
|
Don't put "urgent" in the subject. However urgent you may feel that it is, it's never urgent enough to mention in the subject, or you wouldn't be posting in a forum instead of paying for assistance.
s3rro wrote: I want to make use the values in dequeue in another mehtod, i want to send the each value of the queueue to a method, or want to sign it smthn else How can I do that?
I can't really tell from that what it is that you want to do.
The Dequeue method returns the value. Once you get it, you can do whatever you like with the value. Example:
string value = myQueue.Dequeue();<br />
CallSomeMethod(value);
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hmm, maybe he wants a priority queue - after all, that will allow him to dequeue the urgent items first
|
|
|
|
|
lmoelleb wrote: maybe he wants a priority queue
Right... a SortedQueue is something that's missing in the System.Collections.Generic namespace...
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
how i can understand ,which websites were opend
or
list of websites is open now
is this technology in winxp ?
thanks
micy c# program Developer
|
|
|
|
|
Hi
Any help would be greatly appreciated as I am very new to the .Net world. I was wondering if its possible to convert a string to an object - for example:
public void lala (string strReportName)
{
strReportName report = new strReportName();
report.SetDataSource(someDataSource);
//where the actual value contained within strReportName is
//a Crystal Report within my project
}
Thank you very much.
Linda
|
|
|
|
|
In the above example you are converting the string to a class name. This doesn't make any sense. However, you can create a Typeof Report from the crystal reports namesapce and then assign it using an if statement.
Report report = null;
if(String.Compare(reportName, "SomeReport") == 0)
report = new SomeReport();
To do it the other way would require reflection and is not a good solution in this case.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Hi,
I am trying to create a setup program to deploy a .net 2 web app. When I right-click on the setup project and then go Add -> Project Output, I only see "Content Files" in the Add Project Output Group dialog box. Why do I not see the other options like "Primary output", "Localized resources", "Debug Symbols", etc.?
Any help would be greatly appreciated. Thanks in advance.
Regards,
|
|
|
|
|
Does somebody have any idea (or link) on How to customize the Serial Number Validation in a .NET Setup project?
Please don't tell me to look on the MSDN: I need something more than the % 7 method
Life is not short... the problem is only how you organize yourself
|
|
|
|
|
|
Hello,
I want to create a control like a textbox additionally with a button inside. So i created a new class with base class TextBox. I wrote code into the constructor to create dynamically the button and position ist right-aligned. This works fine but the problem is that longer text is hidden behind the button. Is there any solution for this.
Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.
|
|
|
|
|
tabstop wrote: Is there any solution for this.
Of course there is, place the button to the side of the textbox rather than over it!
tabstop wrote: Using usercontrols is no solution because the new control should look as a textbox with all his properties and methods.
Thats a no-brainer. A usercontrol could have a textbox and button and then just wrap each property/method you would want and pass them through to the textbox.
for example (in the UserControl):
public string Text
{
get{ return this.textBox.Text; }
set{ this.textBox.Text = value; }
}
|
|
|
|
|
Or you could just expose the TextBox directly. Not good practice but I already question the value/validity of a button in a TextBox
|
|
|
|