Showing posts with label Windows Registry. Show all posts
Showing posts with label Windows Registry. Show all posts

Friday, February 8, 2013

Browse the registry just like a UNC path

Periodically I am searching for a registry path and I stumble upon something on the internet telling me to go 10+ subkeys into a hive to find a value. Although not terrible, it's kind of annoying to switch back and forth between regedit and the browser to follow the path down to the key that I need.

After some googling, I found that Mark Russinovich made a command line version of a tool for this, but I wanted a GUI so I decided to write my own registry jump browser tool. It's pretty simple to use, you plug the key into the input box and hit enter or click the browse registry button.

Format for the key path should look like

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Test Key\Test Sub Key
or
hklm\SOFTWARE\Microsoft\Test Key\Test Sub Key

and if the key is present, it will open the registry and navigate down to the key you've input. If the key does not exist, it will tell you that as well.

You may also use a command line version of this using the format below in the command prompt (remember to navigate to it)
regbrowser "hklm\software\microsoft"

You can only have 1 instance of the registry open when doing this, and it is designed for local registry browsing only, FYI.

Enjoy and leave a comment if it is useful for you, or if you have a suggested improvement.



http://www5.zippyshare.com/d/25056500/3177663/RegBrowser.exe

^ new version with help file built in and minor added functionality



http://www17.zippyshare.com/d/54500288/4459293/Registry%20Browser.zip

^ Sorry blogspot doesn't host .zip files

Tuesday, January 15, 2013

So you're getting Event Manager / Application Log code 9669

This event manager code is generated when your Exchange Server 2007 environment has run out of rows to write to in a database column, that hold unique mail header information, per each mail server. There are many posts on the internet as to how to raise the threshold for this table up to the max (database crashing) limit of 32768.

If you've temporarily raised the ceiling, just as congress keeps raising the debt ceiling, you probably realize just as congress does that eventually a limit is going to be reached and everything is going to then crash and burn.

Fortunately for you, Microsoft decided to build a way to monitor this ceiling/threshold.

Open up regedit and navigate to HKLM\System\CurrentControlSet\Services\MSEXchangeIS\Performance

• Modify the string value "Library" from (notice the dll name) [drive you have exchange program files on]\Program Files\Microsoft\Exchange Server\Bin\Perf\%Processor_Architecture%\mdbperf.dll

to

[drive you have exchange program files on]\Program Files\Microsoft\Exchange Server\Bin\Perf\%Processor_Architecture%\mdbperfx.dll

• Go to each server and apply the attached registry file change (rename the file extension appropriately)

• Open perfmon after registry change

• Right click and add counters and then select “MsExchangeIS Mailbox” under the counters and expand it

• Scroll down to “Rows in ReplidMap Table” and click once on it

• In the “Instances of selected object” window below, highlight each database individually and click add and then ok

• Next scale your counters and determine if any of them are approaching the 16383 out of the box limit

• Save the counter report as an html file so you can go back later, run the report again and calculate the rate of change each day, you can also export them as a .tsv (Tab Separated Value) file for sharing.

At this point you can spot check all other databases to see which are also approaching the replica id limit you've coded into the registry. You can also check these values with a powershell command after you've altered the registry key mentioned above.

The code for that is:

Get-mailboxserver | foreach {get-counter –counter “\MSExchangeIS Mailbox(*)\Rows in ReplidMap Table” –sampleinterval 2 –maxsamples 1}

Friday, August 3, 2012

How to get around, bypass or defeat "A program is trying to automatically send email on your behalf" in Outlook 2010

If you've encountered this error like I have, you know it is a pain in the ass. You're writing code and trying to test it and you get blocked by Outlook security. Today I found a good solution that should be more widely available on the internet, then it is. These two registry keys disable that functionality. A C sharp code example is below and what I used to send emails in a console app. It loops and send a new incrementing subject email every 5 seconds. The code is from the internet and other people, that I've tweaked, same as the reg hacks. I have not tried this with some of the other programmatic ways to interact with Office, nor with other versions of Office. This may also work or affect the "A program is trying to access e-mail addresses you have stored in Outlook" as well.


[HKEY_CURRENT_USER\Software\Policies\Microsoft\Security] "CheckAdminSettings"=dword:00000002
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook\Security] "ObjectModelGuard"=dword:00000002 



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Threading;

/*

 Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Policies\Microsoft\Security] "CheckAdminSettings"=dword:00000002
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook\Security] "ObjectModelGuard"=dword:00000002 
  
  
  
 */

namespace LateBindingTest
{
    class OutlookEmailerLateBinding
    {

        private object oApp;
        private object oNameSpace;
        private object oOutboxFolder;
        public static int messageNumber = 0;

        public OutlookEmailerLateBinding()
        {
            int loopNumber = 0;
            Type outlook_app_type;
            object[] parameter = new object[1];
            //Get the excel object
            outlook_app_type = Type.GetTypeFromProgID("Outlook.Application");
            //Create instance of excel
            oApp = Activator.CreateInstance(outlook_app_type);
            //Set the parameter which u want to set
            parameter[0] = "MAPI";
            //Set the Visible property
            oNameSpace = outlook_app_type.InvokeMember("GetNamespace",
            BindingFlags.InvokeMethod, null, oApp, parameter);

            var Logon_parameter = new object[4] { null, null, true, true };
            oNameSpace.GetType().InvokeMember("Logon",
            BindingFlags.InvokeMethod, null, oNameSpace, Logon_parameter);

            var GetDefaultFolder_parameter = new object[1] { 6 };
            oOutboxFolder =
            oNameSpace.GetType().InvokeMember("GetDefaultFolder",
            BindingFlags.InvokeMethod, null, oNameSpace,
            GetDefaultFolder_parameter);

            Console.WriteLine(messageNumber + " - Press enter to exit");
        }

        static void Main(string[] args)
        {
            //int messageNumber = 0;
            while (true)
            {
                messageNumber += 1;
                try
                {
                    OutlookEmailerLateBinding app = new OutlookEmailerLateBinding();
                    app.SendOutlookEmail("user1@domain.com; user2@domain.com", "Duplicate test message email " + messageNumber, "Test message. Testing. Only reply back if you see a duplicate.");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error Stack {0} ", e.Message);
                }

                //Console.ReadLine();

                Thread.Sleep(5000);
            }
        }

        public void SendOutlookEmail(string toValue, string
subjectValue, string bodyValue)
        {
            var CreateItem_parameter = new object[1] { 0 };
            object oMailItem =
oApp.GetType().InvokeMember("CreateItem", BindingFlags.InvokeMethod,
null, oApp, CreateItem_parameter);

            var mail_item_type = oMailItem.GetType();
            mail_item_type.InvokeMember("To",
                BindingFlags.SetProperty, null, oMailItem, new
object[] { toValue });
            mail_item_type.InvokeMember("Subject",
                BindingFlags.SetProperty, null, oMailItem, new
object[] { subjectValue });
            mail_item_type.InvokeMember("Body",
                BindingFlags.SetProperty, null, oMailItem, new
object[] { bodyValue });
            mail_item_type.InvokeMember("Send",
                BindingFlags.InvokeMethod, null, oMailItem, null);

        }

    }
}




On a side note, here is how to do it in PowerShell in a slightly different way by connecting directly to the Client Access Server (CAS).
.
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.Exchange.Management.PowerShell.Admin"}) -eq $null )
  {
    add-pssnapin Microsoft.Exchange.Management.PowerShell.Admin
  }


 $emailattachment = "xx" # full path to attachment file

 $body = "xx" # body of email

 $smtp = new-object Net.Mail.SmtpClient("xxx") # Dns name or IP of your cas server
 $smtpuser = new-object System.Net.networkCredential
 $smtpuser.domain = "xx" # your domain
 $smtpuser.username = "xx" # your username
 $smtpuser.password = "xx" # your password
 $smtp.Credentials = $smtpuser
 
 $SmtpClient = new-object system.net.mail.smtpClient
 $MailMessage = New-Object system.net.mail.mailmessage
 $SmtpClient.Host = "xxx" # Dns name or IP of cas server
 $mailmessage.from = "xxx" # your email address
 $mailmessage.To.add("xx@xx.xx") # email address to send to
 $mailmessage.Subject = "xxx" # subject
 $MailMessage.IsBodyHtml = $False
 $mailmessage.Body = $body 
 $attachment = New-Object System.Net.Mail.Attachment($emailattachment, 'text/plain') # you may have to change the file type or encrypt file with 7zip to get around gmail file attachment restrictions
   $mailmessage.Attachments.Add($attachment)
 $smtp.Send($MailMessage)