public void DisablePopupBlocker(string pcname, string profile)
{
try
{
if (PcNameIsNotNullOrVoid(pcname) && !string.IsNullOrEmpty(profile))
{
pcname = CleanPCName(pcname);
profile = CheckForProfileDotDomain(pcname, profile);
//string filename = backslashes + pcname + @"\" + cshare + @"\Documents and Settings\" + profile + @"\Desktop\Disable PopUp Blocker.bat";
string filename = GetDesktopLocation(profile) +profile + @"\Desktop\Disable PopUp Blocker.bat";
if (File.Exists(filename))
{
File.Delete(filename);
}
try
{
using (StreamWriter writer = new StreamWriter(filename))
{
writer.WriteLine(@"@echo off");
writer.WriteLine(@"");
writer.WriteLine(@"echo Windows Registry Editor Version 5.00 >popup.reg");
writer.WriteLine(@"echo ;Pop up blocker disable >>popup.reg");
writer.WriteLine(@"echo [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2] >>popup.reg");
writer.WriteLine("echo \"1809\"=dword:00000003 >>popup.reg");
writer.WriteLine("echo \"2200\"=dword:00000000 >>popup.reg");
writer.WriteLine("echo \"1609\"=dword:00000000 >>popup.reg");
writer.WriteLine("echo \"2101\"=dword:00000000 >>popup.reg");
writer.WriteLine(@"");
writer.WriteLine(@"regedit.exe /s popup.reg");
writer.WriteLine(@"");
writer.WriteLine(@"del /q popup.reg");
writer.WriteLine(@"del %0");
writer.Flush();
writer.Close();
MessageBox.Show("Created Disable PopUp Blocker.bat on " + profile + "'s Desktop.");
writer.Dispose();
}
}
catch (IOException ioe)
{
MessageBox.Show(ioe.Message);
}
}
}
catch (Exception popupException)
{
MessageBox.Show(popupException.Message);
}
}
Thursday, April 9, 2015
My solution to disable popup blocker(or any registry setting in HKCU) on a remote machine on an IE zone, without GPO.
So basically, the C# writes a Batch file on the user's Desktop that the user must double click so it runs under their credentials, the Batch file then creates a .reg file on the desktop that it in turn runs to change the registry setting in HKCU, then it deletes the .reg and then itself. I was proud of this a few years ago when I wrote it with the 3 nested syntaxes and all. As you can see it relies on other custom methods I wrote, but what you need to do to replicate should be clear.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment