Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate multiple tasks.

Status
Not open for further replies.

kumar3698

IS-IT--Management
May 19, 2013
7
IN
Dear All

I want to automate certain works like below tasks. I need a VB script which will ask for the data and execute. I,m having more than 430 nodes where all of them should be changed by multiple tasks which is described below so i want to automate the task. help me in the regards
Task should do
1 Change ip address, subnet, gateway, prefered dns
2 change computer name
3 should check secondary monitor attached or not and is that monitor capable of HDCP
4 Turn off firewall
5 Delete temporary files
6 Date and time should be pointed to a ntp server
7 should list partitions other than c and ask for new drive letters
8 should turn off autoplay of usb and disk
9 should ask script runner name and id and all the activities should be logged
10 open a port of specific number
11 Restart the computer to settings take effect

And finally it should generate a detailed report of pc and save as xml file.


IS this possible in VB script . Seeking your help
 
What have you tried so far and where in your code are you stuck?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I found the below script but in that i want to add dns along with ip configuration which is in purpose 1. And i don't want purpose 2, 4, 5 to be executed. Along with this my needs should be executed which is like firewall turnoff, Check for secondary monitor etc. Which i described in the question


'==============================================================================='
' Script name : xp-clone-changer-v04.vbe
' Creation Date : 29-10-2003
' OS : Windows XP
' Amendments : See below
' Added auto-capitalization of Asset no. and Workgroup (26-01-2004)
' Added changes to Computername in printer section of registry (26-01-2004)
' Added check for installed memory (03-07-2004)
'
' PURPOSE
' This script carries out the following function(s):-
' 1) Changes the IP address, subnet mask and gateway.
' 2) Changes the Autologon to the 'Windows User' account.
' 3) Changes the Computername and Workgroup.
' 4) Removes the 'Windows User' account from the 'Administrators' group.
' 5) Deletes the desktop shortcut to 'Clone Changer'.
' 6) Shows amount of installed RAM.
' 7) Re-boots the PC so the changes are carried out.
'
'==============================================================================='
'**Start Encode**
Option Explicit 'Enforce strict naming
Dim WSH, FSO
Dim objComputer, objWMIService, objOperatingSystem, objNetAdapter
Dim strTitle, strVersion, strThisPC, strComputername, strCompNameRegPath, strWorkgroup
Dim strCCS, strTcpipParamsRegPath, strIPAddress, strSubnetMask, strGateway, strGatewayMetric
Dim colMEM, colNetAdapters, colOperatingSystems
Dim errEnable, errGateways

'Setup scripting environment
Set WSH = CreateObject ("WSCript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")

'Set Version info
strVersion = "v04"

'Set target PC for WMI
strThisPC = "."

'Set the Title for any dialogs
strTitle = "XP Clone Changer " & strVersion

'------------------------------------------------------------------------
'Section 1 - Use WMI to change IP address, subnet mask and gateway
WSH.Popup "Preparing to change IP address, subnet mask and gateway... Please wait.",2, strTitle 'Inform user

'Setup WMI
Set objWMIService = GetObject("winmgmts:\\" & strThisPC & "\root\cimv2")

'Set specific WMI query so 1394 adapter is excluded
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

'Get user input into an array
strIPAddress = Array(InputBox("Enter the new IP address"))
strSubnetMask = Array(InputBox("Enter the new Subnet mask"))
strGateway = Array(InputBox("Enter the new Gateway address"))

'Inform user
WSH.Popup "Please be patient whilst changes are made. This could take 10 seconds or more.",3, strTitle 'Inform user
strGatewayMetric = Array(1)

'Make the changes
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WSH.Popup "The IP address has been changed.",2,strTitle 'Inform user of success
Else
WSH.Popup "The IP address could not be changed automatically." & vbCrLf & vbCrLf &_
"This may be because the PC/Laptop is not connected to an active network." & vbCrLf & vbCrLf &_
"Please check the IP settings manually afterwards.",2,strTitle 'Inform user of failure
End If
Next
'------------------------------------------------------------------------
'Section 2 - Change the Autologon to 'Windows User' account
WSH.Popup "Preparing to change AutoLogon to Windows User account... Please wait.",2, strTitle

'Change details in the Registry
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName", "Windows User"
WSH.Popup "OK... Done!",2, strTitle 'Inform user
'------------------------------------------------------------------------
'Section 3 - Change Computername and Workgroup
WSH.Popup "Preparing to change Computername.",2, strTitle 'Inform user

'Get user input
strComputername = InputBox("Enter the asset no. to use as the Computername, e.g A051468")
strComputername = UCase(strComputername) 'Force capitalization
WSH.Popup "Please wait.",2, strTitle 'Inform user

'Computername
strCCS = "HKLM\SYSTEM\CurrentControlSet\"
strTcpipParamsRegPath = strCCS & "Services\Tcpip\Parameters\"
strCompNameRegPath = strCCS & "Control\Computername\"

'Delete current settings in registry and write new ones
With WSH
.RegDelete strTcpipParamsRegPath & "Hostname"
.RegDelete strTcpipParamsRegPath & "NV Hostname"

.RegWrite strCompNameRegPath & "Computername\Computername", strComputername
.RegWrite strCompNameRegPath & "ActiveComputername\Computername", strComputername
.RegWrite strTcpipParamsRegPath & "Hostname", strComputername
.RegWrite strTcpipParamsRegPath & "NV Hostname", strComputername
End With ' WSH
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\AltDefaultDomainName", strComputername
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName", strComputername
WSH.RegWrite "HKCU\Software\Microsoft\Windows\ShellNoRoam\", strComputername
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\serverName", LCase(strComputername)
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\shortServerName", strComputername
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\uNCName", "\\" & LCase(strComputername) & "\HP LaserJet 4000 Series PCL"
WSH.RegWrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\url", " & LCase(strComputername) & "/"

WSH.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\serverName", LCase(strComputername)
WSH.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\shortServerName", strComputername
WSH.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\uNCName", "\\" & LCase(strComputername) & "\HP LaserJet 4000 Series PCL"
WSH.RegWrite "HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers\HP LaserJet 4000 Series PCL\DsSpooler\url", " & LCase(strComputername) & "/"

WSH.RegWrite "HKEY_USERS\.DEFAULT\Software\Microsoft\Windows Media\WMSDK\General\Computername", strComputername

WSH.Popup "OK... Done!",2, strTitle 'Inform user

'Workgroup
WSH.Popup "Preparing to change Workgroup.",2, strTitle 'Inform user

'Get user input
strWorkgroup = InputBox("Enter the name to use as the Workgroup, e.g SS38COL")
strWorkgroup = UCase(strWorkgroup) 'Force capitalization
WSH.Popup "Please wait.",2, strTitle 'Inform user

'Use Win2k resource kit utility to make change
WSH.Run "NETDOM.EXE MEMBER \\" & strComputername & " /JOINWorkgroup " & strWorkgroup, 0, True
WSH.Popup "OK... Done!",2, strTitle 'Inform user

'------------------------------------------------------------------------
'Section 4 - Remove Windows User account from Administrators group
WSH.Popup "Preparing to remove Windows User account from Administrators group.",2, strTitle 'Inform user

'Use commandline to carry out removal forcibly in hidden mode
WSH.Run "cmd /c NET LOCALGROUP Administrators " & """Windows User""" & " /DELETE", 2, True
WSH.Popup "OK... Done!",2, strTitle 'Inform user

'------------------------------------------------------------------------
'Section 5 - Delete desktop shortcut
FSO.DeleteFile("C:\Documents and Settings\All Users\Desktop\Clone Changer.lnk"),True

'------------------------------------------------------------------------
'Section 6 - Show amount of installed RAM
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strThisPC & "\root\cimv2")
Set colMEM = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer In colMEM
objComputer.TotalPhysicalMemory = Left((objComputer.TotalPhysicalMemory/1000000),3)
If objComputer.TotalPhysicalMemory < 512 Then
WSH.Popup "Installed memory:" & vbTab & (objComputer.TotalPhysicalMemory) & "Mb"_
& VbCrLf & VbCrLf & "Warning: This PC has less than 512 Mb of memory installed."_
& VbCrLf & "The swap size is set incorrectly and performance will suffer."_
& VbCrLf & VbCrLf & "Please install more memory ASAP." &_
VbCrLf & VbCrLf & "Click on the OK button.", 0, strTitle
Else
WSH.Popup "Installed memory:" & vbTab & (objComputer.TotalPhysicalMemory) & "Mb"_
& VbCrLf & VbCrLf & "Click on the OK button.", 0, strTitle
End If
Next

'------------------------------------------------------------------------
'Section 7 - Use WMI to re-boot PC
WSH.Popup "Re-booting the PC so changes take effect. Please wait...",2, strTitle 'Inform user
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strThisPC & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next

'------------------------------------------------------------------------
'Finish up
Set WSH = Nothing
Set FSO = Nothing
Set objWMIService = Nothing
Set colNetAdapters = Nothing
Set colMEM = Nothing
WScript.Quit 'Yay!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top