|
Dear All,
I am scratching my head about 4 hours to get this sorted, but without any luck.
what i would like to do is on my windows form, it connects to a remote machine and then display all the programs that installed on a windows server 2003 box on a ListBox, then user can select one of the program, and click the Uninstall button to uninstall the selected program.
I am able to load all the programs installed on the remote machines by this code:
public static ArrayList GetAppLists(string p_machineName)
{
RegistryHive hive = RegistryHive.LocalMachine;
RegistryKey subKey;
string displayName, displayVersion, keyNameCurrentMachine32;
ArrayList al = new ArrayList();
keyNameCurrentMachine32 = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey regHive = RegistryKey.OpenRemoteBaseKey(hive, p_machineName))
{
using (RegistryKey regKey = regHive.OpenSubKey(keyNameCurrentMachine32))
{
if (regKey != null)
{
foreach (string k in regKey.GetSubKeyNames())
{
using (subKey = regKey.OpenSubKey(k))
{
displayName = subKey.GetValue("DisplayName") as string;
displayVersion = subKey.GetValue("DisplayVersion") as string;
if (!string.IsNullOrEmpty(displayName))
{
al.Add(displayName + " " + displayVersion);
}
}
}
}
}
}
return al;
}
but when i try to uninstall the particular progarm by this code:
private void UninstallProgram()
{
ConnectionOptions connection = new ConnectionOptions();
connection.Username = txtDomain.Text + "\\" + txtUserName.Text;
connection.Password = txtPassword.Text;
connection.Impersonation = ImpersonationLevel.Impersonate;
connection.Authentication = AuthenticationLevel.Packet;
connection.EnablePrivileges = true;
ManagementScope scope = new ManagementScope(@"\\" + cbServerAddress.Text + "\\root\\cimv2", connection);
ManagementObject app = new ManagementObject(scope,
new ManagementPath("Win32_Product.DisplayName='WinRAR 4.01 (32-bit)', DisplayVersion='4.01.0'"),
null);
MessageBox.Show(app.ToString());
if (app != null)
{
ManagementBaseObject outParams = app.InvokeMethod("Uninstall", null, null);
MessageBox.Show("finished");
}
else
{
MessageBox.Show("cant find app.");
}
}
it always returns "Invalid parameter", and the place throws exception was here:
ManagementObject app = new ManagementObject(scope,
new ManagementPath("Win32_Product.DisplayName='WinRAR 4.01 (32-bit)', DisplayVersion='4.01.0'"),
can someone in here assist me or point me to the right direction will be greatly appreciated.
Many thanks.
Andie
|
|
|
|
|
no one had any clue or i just posted in the wrong section of this forum?
|
|
|
|
|
Hello . I need to use MS Word in my program . i want to create a ms word file from my program and let my user to write his writing or letter or everything and save this document into my database . I do not know how to do this . For example my user wants to write a letter to his boss . so i want to give ability to write it and save that n my database . I do not want to store the address of files . i want to store the whole document in XML datatype Even its template .
so can you help me ?
thanks
|
|
|
|
|
Just start with the basics. Here[^] is a good article on Word Automation to start you off.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I am doing an assignment on Backup + Restore database with Stored Procedures.
Backup is ok, but Restore the error: "RESTORE cannot process database 'db_test' because it is in use by this session. It is recommended that the master database be used when performing this operation.".
I tried to fix but the document has not been, hope admin help with this problem. Thanks!
Link source: http://www.mediafire.com/?c1uldq2t7eczw3b
I use C # VS2010 + sql server 2005.
|
|
|
|
|
You are restoring a database that you are also probably using at the same time.
Try making sure you run a restore in the master database.
|
|
|
|
|
I used sql queries Restore is done, but 'Stored Procedures' are not. So I asked to use the 'Stored Procedures' can not do this. And if so please help me modifying my demo about Restore using 'Stored Procedures'
. Thank you very much.
Link: http://www.mediafire.com/?c1uldq2t7eczw3b
|
|
|
|
|
Hi Guys ,
Stuck up in small issue can u any one please help me out of this.
I have exported a excel report as below. But last statement is not executing. After downloading it i want to navigate to other page, But it is throwing exception. I understood that i am clearing the HTTP Response. But can i cal one more HTTP?? or how can i navigate to other page.. Please help on this
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End()
Response.Redirect("Downloaded.aspx",false); [Problem][Exception]
|
|
|
|
|
Think about it. When you execute Response.End, that's it. There's nothing else being sent to the client. You cannot redirect a client after you call Response.End.
|
|
|
|
|
Always wrap your code in "pre" tag.
|
|
|
|
|
Hi,
I just need your advise please.. where is the best place to save my error.log? is it in the application folder? or some other common folder?
Thanks,
Jassim
|
|
|
|
|
|
Bert Mitton wrote:
I'll usually save it in the application folder.
It's easier to find, and it can't get confused with the error log from another
program.
and is usually read-only to users running the app, so it's impossible (default user permissions) for the log to be written there.
modified 11-Nov-11 8:51am.
|
|
|
|
|
Wait, why is the answer removed? It's an answer (albeit a wrong one), right? I think the answer shouldn't be removed as it can point out a practice that should be avoided. Dave, Can you please include the original answer in your message?
Oxfords English < Official CCC Players Dictionary
Excuse me for my improper grammar and typos.
It's because English is my primary language, not my first language.
My first languages are C# and Java.
VB, ASP, JS, PHP and SQL are my second language.
Indonesian came as my third language.
My fourth language? I'm still creating it, I'll let you know when it's done!
|
|
|
|
|
Nope, 'cause I can't see it either.
|
|
|
|
|
If you edit the answer you gave, it should give you the message that the user posted. This has worked for me in the past.
|
|
|
|
|
|
Windows provides special places, see here[^].
|
|
|
|
|
Generally recommended ... your app should have a folder under the common application data folder for certain users and/or all users. App data folders are usually created by their installers and have their permissions set appropriately for whatever access is required (read write etc.). You should always use the system functions to retrieve the locations of the root special folders (System.Environment.GetFolderPath(), SHGetFolderLocation(), SHGetKnownFolderIDList()) since the paths vary on Windows versions and users can move them.
Folders of interest for (local (non-roaming)) app data:
System.Environment.GetFolderPath(LocalApplicationData)
(Win32 Shell APIs FOLDERID_LocalAppData SIDL_LOCAL_APPDATA)
System.Environment.GetFolderPath(CommonApplicationData)
(Win32 Shell APIs FOLDERID_ProgramData/CSIDL_COMMON_APPDATA)
Mark Salsbery
|
|
|
|
|
Hi.
I want to know how the Google Search Algorithm calculates the information necessary to rank a website. Like, how does it measure inbound/outbound links links, how many times it has been shared on Facebook/Twitter, etc.
The only way I see it is to search every website on the internet, and then write all the outbound links, and then do bunch of math to go through all websites and rank the inbound links. But that would be toooo inefficient.
I'm not sure how it is done, I had a cool project in mind, but I am looking for a more efficient approach than the one I wrote above.
Could please guide me in the right direction?
Thanks!
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson "Why is it drug addicts and computer afficionados are both called users?" - Clifford Stoll
|
|
|
|
|
google "page rank algorithm"
There's a powerpoint presentation, one of the first hit that discuss that.
In short, it works by working graphs and weights and minimum distance and other stuff like that.
and more info on http://en.wikipedia.org/wiki/PageRank[^].
Watched code never compiles.
|
|
|
|
|
Hi,
I am wondering why I am getting this warning in my C# WinForm application in Visual Studio 2010?
Warning 1 A reference was created to embedded interop assembly 'c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\Accessibility.dll' because of an indirect reference to that assembly created by assembly 'c:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Windows.Forms.dll'. Consider changing the 'Embed Interop Types' property on either assembly. Smart PBX Logger
Thanks,
jassim
|
|
|
|
|
|
but I guess it's referring to the accessibility.dll
do i really need ti in my project? is it added by default?
|
|
|
|
|
I try it but not much helpful. please send any other links
|
|
|
|