Command Line archives - Network Administrator Knowledgebase

Network Administrator Knowledgebase:

Command line

Jun 22 2009   7:00AM GMT

Install Windows updates on the command line and in scripts



Posted by: Michael Khanin
windows updates, wsus, Command line

Everybody knows that i’m a real fan of scripting :).
I was really happy to read post of Michael Pietroforte about WuInstall 1.2 Pro

Continue at http://4sysops.com

Oct 31 2008   12:53AM GMT

Install Windows Components from Command Line



Posted by: Michael Khanin
Microsoft Windows, Command line

Windows XP and Windows Server 2000 / 2003 have a built-in utility called the System stand-alone Optional Component Manager (sysocmgr.exe) to programmatically add or remove Windows components. Running sysocmgr.exe with no parameters will display the usage. The most basic command line is:

%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf This parameter (/i:) is always required and specifies the location of the master inf (%windir%\inf\sysoc.inf). When run it simply displays the Windows Components Wizard. Therefore the above command can be used as a shortcut directly to the Windows Components Wizard.

The real power of sysocmgr is in unattended mode. Additional parameters control the user interface, handle restarting, and control which components are added or removed by way of a standard Windows unattended answer file. Sysocmgr only looks in the [Components] and [NetOptionalComponents] sections, so the answer file can be specifically for component management or reused from a Windows unattended installation. Some components have their own unattended answer file sections, which are also parsed.

The following example uses an answer file (/u:) named ocm.txt in the temporary directory (%temp%\ocm.txt), suppresses any necessary restart (/r), and displays no user interface (/q):

%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf /u:%temp%\ocm.txt /r /q

The following example answer file adds the Simple Network Management Protocol (SNMP) service and configures the agent settings:

[NetOptionalComponents]
SNMP = 1

[SNMP]
Contact_Name = Michael Khanin
Location = Canada

Service = Physical, Applications, End-to-End

Community_Name = Public
Traps = server1.thesystemadministrator.comserver2.thesystemadministrator.com

Send_Authentication = Yes
Accept_CommunityName = Public:Read_Only
Any_Host = No
Limit_Host = server1.thesystemadministrator.comserver2.thesystemadministrator.com

Tips:

  • Sysocmgr can only be run by users with local administrative rights. It can be combined with runas, e.g.,

runas /user:admin “%windir%\system32\sysocmgr.exe /i:%windir%\inf\sysoc.inf”

  • Make sure that the target system has the Windows installation source available. The following registry values must point to a source to which the administrative user has access (e.g., if a network path, a local administrator account may not be able to access it):


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]
“SourcePath”=”c:\\windows\\i386″
“Installation Sources”= … (REG_MULTI_SZ value)
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion]
“SourcePath”=”c:\\windows\\i386″

Source: TheSystemAdministrator.com


Oct 24 2008   1:26PM GMT

How to Set Time Zone from Command Line



Posted by: Michael Khanin
Windows Computing, Command line, How to Set Time Zone from Command Line

If you need to change Time Zone for a lot XP computers, you can do this by simple :) command:

RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z Central Standard Time

to change Time Zone to Jerusalem (GMT+02:00) run the following command:

RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z (GMT+02:00) Jerusalem


Jul 19 2008   1:32PM GMT

CoreConfigurator Tool discontinued



Posted by: Michael Khanin
Windows Server 2008, Command line

Guy Teverovsky, notice that CoreConfigurator Tool discontinued. He will not be developing the tool anymore and cannot support it.


Jun 27 2008   10:56PM GMT

Send a Message to All Users in an OU



Posted by: Michael Khanin
Microsoft Windows, send, message, Command line

By using the DSQUERY command and “Net Send” we can send a message to all users in a given OU.
It’s really simple, create a script, name it NetSendOU.bat and use the following syntax:

NetSendOU OU Message

Where OU is the organizational unit, like “OU=Users,DC=AdminInfo,DC=Ca”, and Message is the message text, like “Hello from AdminInfo.ca”.

NetSendOU.bat contains:
@echo off
if {%2}=={} @echo Syntax: NetSendOU OU “Message”&exit /b 1
setlocal
set query=dsquery user %1 -o samid
set message=%2
for /f %%u in (’%query%’) do (net send “%%u” %message%)
endlocal
exit /b 0