{"id":474,"date":"2012-02-01T17:01:19","date_gmt":"2012-02-01T22:01:19","guid":{"rendered":"http:\/\/www.anthonyreinke.com\/?p=474"},"modified":"2018-05-07T20:55:27","modified_gmt":"2018-05-08T02:55:27","slug":"installing-snmp-through-the-command-line-part-2","status":"publish","type":"post","link":"https:\/\/anthonyreinke.com\/index.php\/2012\/02\/01\/installing-snmp-through-the-command-line-part-2\/","title":{"rendered":"Installing SNMP through the Command Line &#8211; Part 2"},"content":{"rendered":"<p>I added a batch script I wrote to install SNMP on a bunch of machine back on Jan. 14, 2012 (<a href=\"http:\/\/www.anthonyreinke.com\/?p=455\">http:\/\/www.anthonyreinke.com\/?p=455<\/a>). \u00a0I have since modified the script. \u00a0Changing the file from a .bat to a .cmd will allow you to right click and run as administrator on Windows 2008. \u00a0Also I noticed in 2008, it defaults in to having the localhost as the only system that can communicate to the SNMP Service.<\/p>\n<p>PsExec.exe @hosts.txt -s -c installsnmp.cmd<\/p>\n<p>Below is the file to download. \u00a0Rename the file to installsnmp.cmd<br \/>\n<a href=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2012\/02\/installsnmp.cmd_.txt\">installsnmp.cmd.txt<\/a><\/p>\n<p>As always, please contact me if you have questions.<\/p>\n<pre><span style=\"color: #008000;\">@echo off<\/span><\/pre>\n<pre><span style=\"color: #008000;\">cls<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Detect if the system is Windows Server 2003\r\nsysteminfo | find \"2003\" &gt; nul\r\nif %ERRORLEVEL% == 0 goto 2003<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Detect if the system is Windows XP\r\nsysteminfo | find \"XP Pro\" &gt; nul\r\nif %ERRORLEVEL% == 0 goto XPPro<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Detect if the system is Windows XP\r\nsysteminfo | find \"2008\" &gt; nul\r\nif %ERRORLEVEL% == 0 goto 2008<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM If the system is Windows Vista, Windows Server 2008, or higher, \r\nREM they have the required files built in.\r\ngoto ERROR<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:2003\r\nREM If Windows 2003, set the path to the i386 directory\r\nREM Note: The path needs to be one level above the i386 directory\r\nREM Example: if the path is \\\\server\\share\\windows2003\\i386\\ then\r\nREM the path would be \\\\server\\share\\windows2003\\\r\nREM Note that the you need both a 32bit and 64bit versions<\/span><\/pre>\n<pre><span style=\"color: #008000;\">if (%PROCESSOR_ARCHITECTURE%) == (AMD64) (\r\necho Windows Registry Editor Version 5.00\r\necho.\r\necho [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup]\r\necho \"SourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\Win2003x64\\\\\"\r\necho \"ServicePackSourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\Win2003x64\\\\\"\r\n) &gt; %temp%\\setW2003Path.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">IF (%PROCESSOR_ARCHITECTURE%) == (x86) (\r\necho Windows Registry Editor Version 5.00\r\necho.\r\necho [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup]\r\necho \"SourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\Win2003\\\\\"\r\necho \"ServicePackSourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\Win2003\\\\\"\r\n) &gt; %temp%\\setW2003Path.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Installing the created Registry File\r\nregedit \/s \/q %temp%\\setW2003Path.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto SNMP<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:XPPro\r\nREM If Windows XP Professional, set the path to the i386 directory\r\nREM Note: The path needs to be one level above the i386 directory\r\nREM Example: if the path is \\\\server\\share\\windowsXP\\i386\\ then\r\nREM the path would be \\\\server\\share\\windowsXP\\\r\nif (%PROCESSOR_ARCHITECTURE%) == (AMD64) (\r\n(\r\necho Windows Registry Editor Version 5.00\r\necho.\r\necho [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup]\r\necho \"SourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\XPProx64\\\\\"\r\necho \"ServicePackSourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\XPProx64\\\\\"\r\n) &gt; %temp%\\setXPProPath.reg\r\n) ELSE IF (%PROCESSOR_ARCHITECTURE%) == (x86)\r\n(\r\necho Windows Registry Editor Version 5.00\r\necho.\r\necho [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup]\r\necho \"SourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\XPPro\\\\\"\r\necho \"ServicePackSourcePath\"=\"\\\\\\\\server\\\\share\\\\Extracted\\\\XPPro\\\\\"\r\n) &gt; %temp%\\setXPProPath.reg\r\n)<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Installing the created Registry File\r\nregedit \/s \/q %temp%\\setXPProPath.reg.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto SNMP<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:2008\r\nREM Since 2008 stopped using the sysocmgr.exe to install features, in Vista and higher\r\nREM you need to use the servermanagercmd.exe to add features. A great list of the \r\nREM features and their command line install string is at:\r\nREM http:\/\/www.techrepublic.com\/blog\/datacenter\/install-windows-server-2008-features-with-servermanagercmd\/294<\/span><\/pre>\n<pre><span style=\"color: #008000;\">servermanagercmd.exe -install SNMP-Services<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto Strings<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:SNMP\r\nREM Building the Unattended Install<\/span><\/pre>\n<pre><span style=\"color: #008000;\">(\r\necho ;SetupMgrTag\r\necho [NetOptionalComponents]\r\necho SNMP=1\r\necho [SNMP]\r\necho Any_Host=YES\r\n) &gt; %temp%\\snmp.txt<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Installing the SNMP application with the Unattended Install<\/span><\/pre>\n<pre><span style=\"color: #008000;\">sysocmgr \/i:%windir%\\inf\\sysoc.inf \/u:%temp%\\snmp.txt<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto Strings<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:Strings<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Removing the public string\r\n(\r\necho Windows Registry Editor Version 5.00\r\necho.\r\necho [-HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\SNMP\\Parameters\\ValidCommunities]<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Removing the only allow localhost communication, by default 2008 will only allow the \r\nREM localhsot to talk to the SNMP service\r\necho [-HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\services\\SNMP\\Parameters\\PermittedManagers]<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Setting the SNMP strings\r\necho.<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Setting the SNMP Contact Info\r\necho [HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\SNMP\\Parameters\\RFC1156Agent]\r\necho \"sysContact\"=\"Server Administrators\"\r\necho \"sysLocation\"=\"Server Room\"\r\necho \"sysServices\"=dword:0000004f\r\necho.\r\nREM Setting the Read Only and Read Write Communities\r\necho [HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\Services\\SNMP\\Parameters\\ValidCommunities]\r\necho \"readonly\"=dword:00000004\r\necho \"readwrite\"=dword:00000008\r\necho.\r\nREM Creating the Permitted Managers Key\r\necho [HKEY_LOCAL_MACHINE\\SYSTEM\\ControlSet001\\services\\SNMP\\Parameters\\PermittedManagers]\r\necho.\r\n) &gt; %temp%\\setupsnmp.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Installing the created Registry File<\/span><\/pre>\n<pre><span style=\"color: #008000;\">regedit \/s \/q %temp%\\setupsnmp.reg<\/span><\/pre>\n<pre><span style=\"color: #008000;\">REM Cleaning Up<\/span><\/pre>\n<pre><span style=\"color: #008000;\">IF EXIST %temp%\\setupsnmp.reg del %temp%\\setupsnmp.reg\r\nIF EXIST %temp%\\setW2003Path.reg del %temp%\\setW2003Path.reg\r\nIF EXIST %temp%\\setXPProPath.reg.reg del %temp%\\setXPProPath.reg.reg\r\nIF EXIST %temp%\\snmp.txt del %temp%\\snmp.txt<\/span><\/pre>\n<pre><span style=\"color: #008000;\">echo %COMPUTERNAME% Complete &gt;&gt; \\\\server\\share\\SNMP\\SNMPInstall.txt<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto END<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:ERROR\r\necho.\r\necho Could not determine the OS type\r\npause<\/span><\/pre>\n<pre><span style=\"color: #008000;\">goto END<\/span><\/pre>\n<pre><span style=\"color: #008000;\">:END<\/span><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I added a batch script I wrote to install SNMP on a bunch of machine back on Jan. 14, 2012 (http:\/\/www.anthonyreinke.com\/?p=455). \u00a0I have since modified the script. \u00a0Changing the file from a .bat to a .cmd will allow you to right click and run as administrator on Windows 2008. \u00a0Also I noticed in 2008, it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[16,19,17,21,18,20,15],"class_list":["post-474","post","type-post","status-publish","format-standard","hentry","category-projects","tag-batch","tag-cli","tag-command","tag-install","tag-line-command-line","tag-snmp","tag-windows"],"_links":{"self":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/comments?post=474"}],"version-history":[{"count":2,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":12411,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/474\/revisions\/12411"}],"wp:attachment":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/media?parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/categories?post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/tags?post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}