> Tech > Listing 1

Listing 1

Tech - Par Renaud ROSSET - Publié le 24 juin 2010
email

FinalSetup.vbs

'**********************************************************************
' TITLE: FinalSetup.VBS Ver 2.0
' USE: Use this to add domain global groups to local groups after the
' computer has joined the domain (WIN 2000 Image).
'**********************************************************************
OPTION EXPLICIT 'Ensures variables are declared.
ON ERROR RESUME NEXT 'Keeps script moving past errors.
'***************************************************
'Declare variables.
'***************************************************

Listing 1

Dim oGroup ‘ADSI object created by GetObject
Dim oWshShell ‘Shell object to run executable (smsman.exe)
Dim sInDomain ‘Used to test domain membership
Dim sCompName ‘Local computer name
Dim oWshNet ‘WshNetwork object
Dim sUser ‘Username for error checking
Dim sMember ‘Check for group membership 0 or 1
‘********************************************************
‘ Declare constants.
‘********************************************************
Const GLOBAL_GROUP = « WEBDEV » ‘Global group being added to local group
Const LOCAL_GROUP = « Administrators » ‘Name of local group
Const DOMAIN = « GONDOR » ‘Domain name
‘********************************************************
‘ Create objects.
‘********************************************************
‘Create network object.
Set oWshNet = Wscript.CreateObject(« Wscript.Network »)
‘Create shell object.
Set oWshShell = Wscript.CreateObject(« Wscript.Shell »)
‘***************************************************
‘ Get local information.
‘***************************************************
sUser = oWshNet.Username ‘Get logon name of current user.
SCompName = oWshNet.Computername ‘Get computer name.
‘***************************************************
‘Confirm Administrator is logged on; quit if not.
‘***************************************************
IF UCASE(sUser) <> « ADMINISTRATOR » THEN
Wscript.Echo « You must be logged in as «  »ADMINISTRATOR » » to run this  » & _
« script!  » & vbCRLF & vbCRLF & « Log off and login as  » & _
«  » »ADMINISTRATOR » » to the local machine  » & « ( » & sCompName & « ). » & _
vbCRLF & vbCRLF & « After logging in as ADMINISTRATOR, run the  » & _
« C:\WINNT\SYSTEM32\FinalSetup.vbs script again » & _
 » to finish the installation. »
Wscript.Quit
END IF
‘***************************************************
‘Make sure the machine has been added to the domain;
‘if not, quit and display message.
_***************************************************
‘Get key value from registry.
sInDomain = oWshShell.RegRead(« HKLM\SOFTWARE\ » & _
« Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache\GONDOR »)
IF sInDomain = «  » THEN
Wscript.Echo « The Computer does not belong to  » & DOMAIN &  » domain! »
Wscript.quit
END IF
IF ERR.NUMBER = -2147024894 THEN
Wscript.Echo « The Computer does not belong to  » & DOMAIN &  » domain! »
Wscript.quit
END IF
‘********************************************************
‘ Modify group memberships.
‘********************************************************
Set oGroup = GetObject(« WinNT:// » & sCompName & « / » & LOCAL_GROUP & « ,group »)
sMember = oGroup.IsMember(« WinNT:// » & DOMAIN & « / » & GLOBAL_GROUP) ‘If a
‘member, will return -1. If not, 0.
IF sMember = 0 THEN
oGroup.add(« WinNT:// » & DOMAIN & « / » & GLOBAL_GROUP)
sMember = oGroup.IsMember(« WinNT:// » & DOMAIN & « / » & GLOBAL_GROUP)
‘If a member, will return -1. If not, 0.
IF sMember = -1 THEN
oWshShell.Popup « The  » & GLOBAL_GROUP &  » global group has been  » & _
« successfully added to the  » & LOCAL_GROUP &  » local group. », & _
5, « Local Group Modified », 064
End IF
ELSE
oWshShell.Popup « The  » & GLOBAL_GROUP &  » global group is already » & _
 » a member of the  » & LOCAL_GROUP &  » local group. », 5, & _
« Global Group Exists » ,064
End IF
‘********************************************************
‘Run smsman.exe to install SMS 2.0.
‘********************************************************
oWshShell.Popup « SMS 2.0 will now be installed. Please wait while » & _
 » program is loading… » & vbCRLF & vbCRLF & « The SMS Client » & _
 » Installation will take approximately 5 minutes to complete » & _
, 10, « SMS 2.0 Installation », 064
oWshNet.MapNetworkDrive « N: », « \\SMSCPS1\SMSLOGON », , « guest », «  »
oWshShell.Run « N:\x86.bin\00000409\SMSMAN.EXE », ,TRUE
oWshNet.RemoveNetworkDrive « N: »
‘********************************************************
‘Display end-of-script message and exit.
‘********************************************************
MsgBox « This portion of the setup has been completed.  » & _
« Logoff and login as the user and setup the printers. »

Téléchargez cette ressource

Guide de technologie 5G pour l’entreprise

Guide de technologie 5G pour l’entreprise

Pourquoi la 5G est-elle faite pour votre entreprise ? La 5G peut améliorer la vitesse, la fiabilité et la capacité de votre réseau, permettant ainsi une meilleure collaboration, une productivité accrue et une prise de décision plus rapide. Notre livre blanc " The Big Book of Enterprise 5G" vous fournit les informations stratégiques dont vous avez besoin pour prendre des décisions éclairées et préparer votre entreprise à prospérer dans l'ère de la 5G. Cradlepoint, part of Ericsson est le leader mondial des solutions de réseau sans fil 4G LTE et 5G fournies via le cloud. Connectez vos employés, lieux et objets avec la 4G LTE et la 5G pour un WAN sans fil d'entreprise.

Tech - Par Renaud ROSSET - Publié le 24 juin 2010