Microsoft VBScript compilation error: Expected ' | Newbie | | Join Date: Sep 2009
Posts: 2
| |
Hi, I am brand new to VB, and I am trying to deploy Office 2007 on my network here at work. We used part of this script to do another deployment, and I have taken pieces and tried to edit for this deployment. I know I am probably way off the mark, but I would appreciate any help. This is the initial error I receive when running the script. - C:\bkuptestpc\kr_migrate.vbs(276, 1) Microsoft VBScript compilation error: Expected 'End'
-
Exit code: 1 , 0001h[/b] coderror Resume NeatNetwork")
Here's the code - - On Error Resume Next
-
Set objNet = CreateObject("WScript.Network")
-
Set shell = CreateObject("WScript.Shell")
-
Set objFSO = CreateObject("Scripting.FileSystemObject")
-
-
WScript.Echo ""
-
WScript.Echo " __ ____ __ ___"
-
WScript.Echo " / |/ (_)__ ________ _/ /____ _ _< /"
-
WScript.Echo " / /|_/ / / _ `/ __/ _ `/ __/ -_) | |/ / / "
-
WScript.Echo " /_/ /_/_/\_, /_/ \_,_/\__/\__/ |___/_/ "
-
WScript.Echo " /___/ "
-
WScript.Echo " DCSB Office 2007 Enterprise Migration Script Version kr.1 "
-
WScript.Echo ""
-
-
markerfile = "c:\office.2007.1"
-
MarkerFileFlag = 0
-
NetwareInstalledFlag = 0
-
RebootFlag = 0
-
-
WriteLog ""
-
WriteLog "*********************START*********************"
-
WriteLog "Checking for marker file: " & markerfile
-
-
If objFSO.FileExists("c:\office.2007.1") = True Then
-
WriteLog "Office Marker file exists"
-
MarkerFileFlag = 1
-
Else
-
WriteLog "Marker file missing..."
-
MarkerFileFlag = 0
-
End If
-
-
If WScript.Arguments.Count > 0 Then
-
logonServer = trim(LCase(WScript.Arguments.Item(0)))
-
If InStr(logonServer, "\\") = 0 Then
-
logonServer = "\\" & logonServer
-
End If
-
WriteLog "Logonserver Administratively set to, " & logonServer
-
Else
-
logonServer = shell.ExpandEnvironmentStrings("%logonserver%")
-
WriteLog "Logonserver detected: " & logonServer
-
End If
-
-
shell.run "%comspec% /c " & logonServer & "\netlogon\disableclose.exe Migrate",0,False
-
-
If checkLocalAdmin = False Then
-
WriteLog "ERROR - User is not a local administrator"
-
WriteLog "WARNING - Launching KR_Migrate.vbs as a local administrator"
-
shell.Run "%comspec% /c " & logonServer & "\netlogon\cpau.exe -u central\chriss -p ce11ph0ne -ex ""%comspec% /c %windir%\system32\cscript.exe //nologo " & logonServer & "\netlogon\kr_migrate.vbs " & logonServer & """ -profile -wait -title Migrate",1,True
-
-
WScript.Quit 1
-
Else
-
LocalAdmin = "TRUE"
-
End If
-
-
WriteLog ""
-
WriteLog "DCSB Office2007 Migration Script"
-
WriteLog "User: " & objNet.UserName
-
WriteLog "Computer: " & objNet.ComputerName
-
WriteLog "User Domain: " & objNet.UserDomain
-
WriteLog "Time: " & Time
-
WriteLog "Date: " & Date
-
WriteLog "LocalAdmin: " & localAdmin
-
WriteLog "Logfile: " & "\\dcsb8\sys\office-install\logs\" & shell.ExpandEnvironmentStrings("%computername%") & "_" & shell.ExpandEnvironmentStrings("%username%") & ".log"
-
WriteLog ""
-
-
DeploymentServer = GetDistroServer
-
-
If MarkerFileFlag = 0 Then
-
WriteLog "Looking for Office 2007"
-
if GetInstalledProductWMI("Microsoft Office 2007") = "present" Then
-
O2K7Found = 1
-
End If
-
-
if GetInstalledProductREG("Microsoft Office 2007") = "present" Then
-
O2K7Found = 1
-
End If
-
-
If O2K7Found = 1 Then
-
WriteLog "Microsoft Office 2007 Detected"
-
RepairCDCache
-
UninstallOffice2007
-
RebootFlag = RebootFlag + 1
-
Else
-
WriteLog "Microsoft Office 2007 Not Detected"
-
End If
-
-
Set wshShell = WScript.CreateObject("WScript.Shell")
-
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
-
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
-
For Each objSoftware in colSoftware
-
If objSoftware.Caption = "Microsoft Office Enterprise 2007" Then
-
OfficeInstalled = True
-
Exit For
-
End If
-
Next
-
If OfficeInstalled <> True Then
-
Set oExec = wshShell.Exec ("\\company.local\Public\Applications\Office2007\SETUP.EXE")
-
Do While oExec.Status = 0
-
WScript.Sleep 100
-
Loop
-
End If
-
-
Function GetDistroServer
-
WriteLog "Determining distribution server"
-
Set shell = CreateObject("WScript.Shell")
-
Set objFSO = CreateObject("Scripting.FileSystemObject")
-
Set ipconfig = shell.Exec("%comspec% /c ipconfig")
-
-
GetDistroServer = "\\dcsb8"
-
-
deploymentPath = "\\dcsb8"
-
-
ipConfigResults = lcase(ipconfig.StdOut.ReadAll())
-
arrIpConfigResults = Split(ipConfigResults, VbCrLf)
-
-
For Each line In arrIpConfigResults
-
line = replace(Trim(line), " ", "")
-
'WScript.Echo line
-
If InStr(line, "subnetmask") > 0 Then
-
arrSubNetMask = Split(Line, ":")
-
SubNetMask = arrSubNetMask(1)
-
End If
-
If InStr(line, "ipaddress") > 0 Then
-
arrIPAddress = Split(Line, ":")
-
IPAddress = arrIPAddress(1)
-
End If
-
If InStr(line, "defaultgateway") > 0 Then
-
arrGW = Split(Line, ":")
-
GW = arrGW(1)
-
End If
-
Next
-
-
WriteLog "IP Address: " & IPAddress
-
WriteLog "Subnet Mask: " & SubNetMask
-
WriteLog "Default Gateway " & GW
-
-
DeploymentPathFound = 0
-
-
If InStr(IPAddress, "207.203.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\dcsb-ex"
-
If objFSO.FolderExists(deploymentPath & "\sys\Office-Install\kr_2007\Applications\Office 2007") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.1.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\clifton"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.2.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\crossroads"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.3.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\dcsb8"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.4.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\servicecenter"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.6.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\north"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.7.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\kirkwood"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.8.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\enterprises"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If InStr(IPAddress, "10.20.15.") > 0 Then
-
DeploymentPathFound = 1
-
deploymentPath = "\\dcsb8"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - cannot connect to deployment server " & deploymentPath
-
DeploymentPathFound = 0
-
End If
-
End If
-
-
If DeploymentPathFound = 0 Then
-
deploymentPath = "\\dcsb-ex"
-
WriteLog "Unable to locate a distribution server for this computer!"
-
WriteLog "Falling back to \\dcsb-ex"
-
If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
-
WriteLog "Error - Unable to use fall back server " & deploymentPath
-
WriteLog "TERMINATING SCRIPT"
-
DeploymentPathFound = 0
-
WScript.Quit 1
-
End If
-
End If
-
-
WriteLog "Distribution Server: " & deploymentPath
-
GetDistroServer = deploymentPath
-
-
End Function
-
-
-
Function RepairCDCache
-
writeLog "Checking CDCache Value"
-
-
HKEY_CURRENT_USER = &H80000001
-
HKEY_LOCAL_MACHINE = &H80000002
-
-
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
-
-
strKeyPath = "SOFTWARE\Microsoft\Office\11.0\Delivery\{90110409-6000-11D3-8CFE-0150048383C9}"
-
strValueName = "CDCache"
-
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
-
currentCDCache = strValue
-
-
if trim(currentCDCache) = "2" Then
-
writeLog "Changing CDCache value to 0"
-
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,"0"
-
end If
-
-
if trim(currentCDCache) = "0" Then
-
writeLog "CDCache value is set to 0"
-
-
end If
-
-
end Function
-
-
Function SetDefaultDomainLogon(defaultDomain)
-
WriteLog "Setting default logon domain to, " & defaultDomain
-
-
HKEY_CURRENT_USER = &H80000001
-
HKEY_LOCAL_MACHINE = &H80000002
-
-
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
-
-
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
-
strValueName = "DefaultDomainName"
-
oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,defaultDomain
-
-
End Function
|  | Expert | | Join Date: Apr 2007 Location: Mexico City
Posts: 1,155
| | | re: Microsoft VBScript compilation error: Expected '
here: - If WScript.Arguments.Count > 0 Then
-
logonServer = trim(LCase(WScript.Arguments.Item(0)))
-
If InStr(logonServer, "\\") = 0 Then
-
logonServer = "\\" & logonServer
-
End If
there's an END IF missing, or the second part should be in the same line.
Perhaps that's not the only END something missing.
PS try using codetags next time, that'll help us tell you where the errors might be.
| | Newbie | | Join Date: Sep 2009
Posts: 2
| | | re: Microsoft VBScript compilation error: Expected '
Okay, Thanks for your help. I will check for that when I return to the office after the weekend.
|  | Similar Visual Basic 4 / 5 / 6 bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|