Jump to content

Valvaris

Member
  • Posts

    12
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Germany

About Valvaris

Profile Information

  • OS
    Windows 10 x64

Valvaris's Achievements

0

Reputation

  1. Hi, wow thanks will give it a try at Monday next week. and there is more code but it has nothing to do with this and is sepperated by other events ------------ Thank you for the advice to write the comments in xml will look more in to this -------------- Best regards Val.
  2. Hi @ all, its me again. This time i cant figure out why i cant get the folders to delete - and recieve a Path not found error. Situation -> There are paths to delete but sometimes the path dosent exist and the deletion process has to go an. Example -> PATH A, PATH B, PATH C ----- Some Computers have all 3 Paths but Some of them only have PATH A and C or PATH A and B or only PATH C. In CMD there is not problem - IT will Prompt for an error but goes on - in C Sharp it gets an error and Stops the Process of Deletion. AND PATH has to remein Dynamic becouse sometimes the Folder is under C: or D: on some PCs. Here my Code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows; using System.Windows.Forms; using System.Security.Principal; using System.Diagnostics; using Microsoft.Win32; using System.Threading; using System.IO; private void button4_Click(object sender, EventArgs e) { string f1 = Directory.GetCurrentDirectory() + @"\TEST\TEST2\TEST3"; Directory.Delete(f1); //Weiter Thread.Sleep(2000); string f2 = Directory.GetCurrentDirectory() + @"\TEST8\TEST4"; Directory.Delete(f2); //Weiter Thread.Sleep(2000); string f3 = Directory.GetCurrentDirectory() + @"\AA\BB"; Directory.Delete(f3); //Weiter Thread.Sleep(2000); string f4 = Directory.GetCurrentDirectory() + @"\DD\EE\FF"; Directory.Delete(f4); //Weiter Thread.Sleep(2000); string f5 = Directory.GetCurrentDirectory() + @"\More\to\Test"; Directory.Delete(f5); //Weiter Thread.Sleep(2000); string f6 = Directory.GetCurrentDirectory() + @"\its\fun"; Directory.Delete(f6); //Weiter Thread.Sleep(2000); string f7 = Directory.GetCurrentDirectory() + @"\more"; Directory.Delete(f7); //Weiter Thread.Sleep(2000); string f8 = Directory.GetCurrentDirectory() + @"\done\testing"; Directory.Delete(f8); //ENDE } Thanks allot in advance. Best regards Val.
  3. Hi @ all, im in a Projekt to help my co Workers with a little app to save time in uninstallig a special app - My Goal is to write this tool in Framework 2.0 (Windows Forms Projekt) and later after 6-8Months to Framework 3.5. OK now to my question - I know it sounds N00b but need help on how to setoff multiple commands to scan registry on a button. My Code Looks like so: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows; using System.Windows.Forms; using System.Security.Principal; using System.Diagnostics; using Microsoft.Win32; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button5_Click(object sender, EventArgs e) { WindowsIdentity wi = WindowsIdentity.GetCurrent(); WindowsPrincipal wp = new WindowsPrincipal(wi); if (wp.IsInRole(WindowsBuiltInRole.Administrator)) // Ok, user is administrator MessageBox.Show("OK"); else // Non privileged user, not ok to continue... MessageBox.Show("Nooooooo"); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string mailtoString = @"mailto:xxx@xxx.xx"; Process.Start(mailtoString); } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void button2_Click(object sender, EventArgs e) { string MyKeyName = "HKEY_LOCAL_MACHINE\\Software\\Test\\Product\\PAA003XX\\Versions\\1.0"; string MyKeyName1 = "HKEY_LOCAL_MACHINE\\Software\\Test\\Packages\\PAA003YY\\Versions\\1.0"; string MyValueName = "CompVersion"; string MyValueName1 = "CompVersion"; string MyValue = "####"; string MyValue1 = "####"; object MyObject = null; object MyObject1 = null; //Registry.GetValue returns an object: MyObject1 = Registry.GetValue(MyKeyName1, MyValueName1, null); if (MyValue1 != "####") { //Get the string value of the object returned: MyValue1 = MyObject1.ToString(); MessageBox.Show("Product Version = " + MyValue1); } else { MessageBox.Show("Product X not found"); } MyObject = Registry.GetValue(MyKeyName, MyValueName, null); if (MyValue != "####") { //Get the string value of the object returned: MyValue = MyObject.ToString(); MessageBox.Show("Product Version = " + MyValue); } else { MessageBox.Show("Product Y not found"); } } } } Main Code of problem is the Event from private void button2_Click(object sender, EventArgs e) - Downwards the rest is kinda ok. how do i get this to work im very new to C Sharp still need to learn allot. Many MAny thx in advance Val. --------------------- UPDATE ------------------------- ----------------------SOLVED------------------ Yes I did it --> So this is the Code I use now and it works! using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows; using System.Windows.Forms; using System.Security.Principal; using System.Diagnostics; using Microsoft.Win32; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button5_Click(object sender, EventArgs e) { WindowsIdentity wi = WindowsIdentity.GetCurrent(); WindowsPrincipal wp = new WindowsPrincipal(wi); if (wp.IsInRole(WindowsBuiltInRole.Administrator)) // Ok, user is power user or administrator MessageBox.Show("OK"); else // Non privileged user, not ok to continue... MessageBox.Show("Nooooooo"); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string mailtoString = @"mailto:xxxx@xxxxx.xx"; Process.Start(mailtoString); } private void button3_Click(object sender, EventArgs e) { this.Close(); } private void button2_Click(object sender, EventArgs e) { string MyKeyName = "HKEY_LOCAL_MACHINE\\Software\\XXXXX\\Packages\\PYY003XX\\Versions\\1.0"; string MyKeyName1 = "HKEY_LOCAL_MACHINE\\Software\\YYYYY\\Packages\\PYY003YY\\Versions\\1.0"; string MyValueName = "CompVersion"; string MyValueName1 = "CompVersion"; string MyValue = ""; string MyValue1 = ""; object MyObject = null; object MyObject1 = null; //Registry.GetValue returns an object: MyObject = Registry.GetValue(MyKeyName, MyValueName, null); if (MyObject != null) { //Get the string value of the object returned: MyValue = MyObject.ToString(); MessageBox.Show("Product X Version = " + MyValue); } else { MessageBox.Show("Product X not found!"); MyObject1 = Registry.GetValue(MyKeyName1, MyValueName1, null); if (MyObject1 != null) { //Get the string value of the object returned: MyValue1 = MyObject1.ToString(); MessageBox.Show("Product Y Version = " + MyValue1); } else { MessageBox.Show("Product Y not found!"); } } } } } So what happened ive mixed the MyObject with the MyValue and recieved a String Error if nothing was found and if something got found nothing will happen becouse it got stuck. Now it searches for Product X and if thatone got found its done - But if Product X wasnt found it will search for Product Y and then its done ---- IF Found dialouge with Version of Product X/or/Y or a Message!!! So many many Thanks @ all - Bestregards HAppy Holidays @ ll and BEst regards Val.
×
×
  • Create New...