Skip to content

Instantly share code, notes, and snippets.

@FennyFatal
Created July 31, 2014 00:17
Show Gist options
  • Save FennyFatal/81c81737db532000958d to your computer and use it in GitHub Desktop.
Save FennyFatal/81c81737db532000958d to your computer and use it in GitHub Desktop.
public static void launchRemotePrintMgmt(String computerName)
{
String pmc_xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <pmc-configuration xmlns=\"http://schemas.microsoft.com/2003/print/pmc/config/1.0\"><_locDefinition><_locDefault _loc=\"locNone\"/><_locTag _loc=\"locData\" _locAttrData=\"name\">filter</_locTag></_locDefinition><print-servers-standalone><server xmlns=\"\" uncname=\"\\\\"
+ computerName
+ "\" servername=\""
+ computerName
+ "\"/></print-servers-standalone><filters><filter name=\"Printers With Jobs\" description=\"filter:jobs_in_queue GREATER_THAN '0'\" shownumprinters=\"false\"><notification emailenabled=\"false\" emailto=\"\" emailfrom=\"\" emailsmtpserver=\"\" emailmessage=\"\" scriptenabled=\"false\" scriptpath=\"\" scriptargs=\"\"/><sexp neg=\"false\" fld=\"jobs_in_queue\" op=\"greater_than\" value=\"0\"/></filter><filter name=\"Printers Not Ready\" description=\"filter:NOT queue_status IS_EXACTLY 'ready'\" shownumprinters=\"false\"><notification emailenabled=\"false\" emailto=\"\" emailfrom=\"\" emailsmtpserver=\"\" emailmessage=\"\" scriptenabled=\"false\" scriptpath=\"\" scriptargs=\"\"/><sexp neg=\"false\" fld=\"queue_status\" op=\"is_exactly_not\" value=\"0\"/></filter></filters><miscellaneous-settings><printers-folder-show-extended-view value=\"0\"/></miscellaneous-settings></pmc-configuration>";
String MSC_Cnts = "<?xml version=\"1.0\"?><MMC_ConsoleFile ConsoleVersion=\"3.0\" ProgramMode=\"UserSDI\"><ConsoleFileID>{E7773B4A-9E7E-4642-B707-F87D531C1A1D}</ConsoleFileID><FrameState ShowStatusBar=\"true\" PreventViewCustomization=\"true\"><WindowPlacement ShowCommand=\"SW_SHOWNORMAL\"><Point Name=\"MinPosition\" X=\"-1\" Y=\"-1\"/><Point Name=\"MaxPosition\" X=\"-1\" Y=\"-1\"/><Rectangle Name=\"NormalPosition\" Top=\"219\" Bottom=\"979\" Left=\"416\" Right=\"1856\"/> </WindowPlacement> </FrameState> <Views> <View ID=\"2\" ScopePaneWidth=\"292\" ActionsPaneWidth=\"-1\"> <BookMark Name=\"RootNode\" NodeID=\"2\"> <DynamicPath> <Segment String=\"Print Servers\"/> <Segment String=\""
+ computerName
+ "\"/> </DynamicPath> </BookMark> <BookMark Name=\"SelectedNode\" NodeID=\"2\"> <DynamicPath> <Segment String=\"Print Servers\"/> <Segment String=\""
+ computerName
+ "\"/> </DynamicPath> </BookMark> <WindowPlacement WPF_RESTORETOMAXIMIZED=\"true\" ShowCommand=\"SW_SHOWMAXIMIZED\"> <Point Name=\"MinPosition\" X=\"-1\" Y=\"-1\"/> <Point Name=\"MaxPosition\" X=\"-8\" Y=\"-30\"/> <Rectangle Name=\"NormalPosition\" Top=\"25\" Bottom=\"495\" Left=\"25\" Right=\"1211\"/> </WindowPlacement> <ViewOptions ViewMode=\"Report\" ScopePaneVisible=\"true\" ActionsPaneVisible=\"true\" DescriptionBarVisible=\"false\" DefaultColumn0Width=\"200\" DefaultColumn1Width=\"0\"/> </View> </Views> <VisualAttributes> <String Name=\"ApplicationTitle\" ID=\"2\"/> </VisualAttributes> <Favorites> <Favorite TYPE=\"Group\"> <String Name=\"Name\" ID=\"1\"/> <Favorites/> </Favorite> </Favorites> <ScopeTree> <SnapinCache> <Snapin CLSID=\"{7C606A3F-8AA8-4E36-92D6-2B6AFEC0B732}\" AllExtensionsEnabled=\"false\"> <Extensions/> </Snapin> <Snapin CLSID=\"{C96401CC-0E17-11D3-885B-00C04F72C717}\" AllExtensionsEnabled=\"true\"/> <Snapin CLSID=\"{D06342BD-9057-4673-B43A-0E9BBBE99F11}\" AllExtensionsEnabled=\"true\"/> </SnapinCache><Nodes> <Node ID=\"2\" ImageIdx=\"0\" CLSID=\"{D06342BD-9057-4673-B43A-0E9BBBE99F11}\" Preload=\"true\"> <Nodes/> <String Name=\"Name\" ID=\"2\"/> <SnapinProperties/> <ComponentDatas> <ComponentData> <GUID Name=\"Snapin\">{D06342BD-9057-4673-B43A-0E9BBBE99F11}</GUID> <Stream BinaryRefIndex=\"0\"/> </ComponentData> </ComponentDatas> <Components/> </Node></Nodes> </ScopeTree> <ConsoleTaskpads/> <ViewSettingsCache> <TargetView ViewID=\"2\" NodeTypeGUID=\"{E29E1970-5CFD-4513-9086-458E353BD439}\"/> <ViewSettings Flag_TaskPadID=\"true\" Age=\"1\"> <GUID>{00000000-0000-0000-0000-000000000000}</GUID> </ViewSettings> </ViewSettingsCache> <ColumnSettingsCache/> <StringTables> <IdentifierPool AbsoluteMin=\"1\" AbsoluteMax=\"65535\" NextAvailable=\"4\"/> <StringTable> <GUID>{71E5B33E-1064-11D2-808F-0000F875A9CE}</GUID> <Strings> <String ID=\"1\" Refs=\"1\">Favorites</String> <String ID=\"2\" Refs=\"1\">Print Management</String> <String ID=\"3\" Refs=\"2\">Console Root</String> </Strings> </StringTable> </StringTables> <BinaryStorage> <Binary>"
+ Convert.ToBase64String(Encoding.UTF8.GetBytes(pmc_xml))
+ "</Binary> </BinaryStorage></MMC_ConsoleFile>";
String MYMSC_File = Path.GetTempFileName();
File.WriteAllText(MYMSC_File, MSC_Cnts);
Process.Start("mmc", MYMSC_File);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment