By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,444 Members | 3,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,444 IT Pros & Developers. It's quick & easy.

Microsoft VBScript compilation error: Expected '

P: 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.
Expand|Select|Wrap|Line Numbers
  1. C:\bkuptestpc\kr_migrate.vbs(276, 1) Microsoft VBScript compilation error: Expected 'End'
  2. Exit code: 1 , 0001h[/b] coderror Resume NeatNetwork")
Here's the code -

Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. Set objNet = CreateObject("WScript.Network")
  3. Set shell  = CreateObject("WScript.Shell")
  4. Set objFSO = CreateObject("Scripting.FileSystemObject")
  5.  
  6. WScript.Echo ""
  7. WScript.Echo "    __  ____               __            ___"
  8. WScript.Echo "   /  |/  (_)__ ________ _/ /____   _  _<  /"
  9. WScript.Echo "  / /|_/ / / _ `/ __/ _ `/ __/ -_) | |/ / / "
  10. WScript.Echo " /_/  /_/_/\_, /_/  \_,_/\__/\__/  |___/_/  "
  11. WScript.Echo "          /___/ "         
  12. WScript.Echo "    DCSB Office 2007 Enterprise Migration Script Version kr.1   "
  13. WScript.Echo ""
  14.  
  15. markerfile = "c:\office.2007.1"
  16. MarkerFileFlag = 0
  17. NetwareInstalledFlag = 0
  18. RebootFlag = 0
  19.  
  20. WriteLog ""
  21. WriteLog "*********************START*********************"
  22. WriteLog "Checking for marker file: " & markerfile
  23.  
  24. If objFSO.FileExists("c:\office.2007.1") = True Then
  25.     WriteLog "Office Marker file exists"
  26.     MarkerFileFlag = 1
  27. Else
  28.     WriteLog "Marker file missing..."
  29.     MarkerFileFlag = 0
  30. End If
  31.  
  32. If WScript.Arguments.Count > 0 Then
  33.     logonServer = trim(LCase(WScript.Arguments.Item(0)))
  34.     If InStr(logonServer, "\\") = 0 Then
  35.         logonServer = "\\" & logonServer
  36.     End If
  37.     WriteLog "Logonserver Administratively set to, " & logonServer
  38. Else
  39.     logonServer = shell.ExpandEnvironmentStrings("%logonserver%")
  40.     WriteLog "Logonserver detected: " & logonServer
  41. End If
  42.  
  43. shell.run "%comspec% /c " & logonServer & "\netlogon\disableclose.exe Migrate",0,False
  44.  
  45. If checkLocalAdmin = False Then
  46.     WriteLog "ERROR - User is not a local administrator"
  47.     WriteLog "WARNING - Launching KR_Migrate.vbs as a local administrator"
  48.     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
  49.  
  50.     WScript.Quit 1
  51. Else
  52.     LocalAdmin = "TRUE"
  53. End If    
  54.  
  55. WriteLog ""
  56. WriteLog "DCSB Office2007 Migration Script"
  57. WriteLog "User: " & objNet.UserName
  58. WriteLog "Computer: " & objNet.ComputerName
  59. WriteLog "User Domain: " & objNet.UserDomain
  60. WriteLog "Time: " & Time
  61. WriteLog "Date: " & Date
  62. WriteLog "LocalAdmin: " & localAdmin
  63. WriteLog "Logfile: " & "\\dcsb8\sys\office-install\logs\" & shell.ExpandEnvironmentStrings("%computername%") & "_" & shell.ExpandEnvironmentStrings("%username%") & ".log"
  64. WriteLog ""
  65.  
  66. DeploymentServer = GetDistroServer
  67.  
  68. If MarkerFileFlag = 0 Then
  69.     WriteLog "Looking for Office 2007"
  70.     if GetInstalledProductWMI("Microsoft Office 2007") = "present" Then
  71.         O2K7Found = 1            
  72.     End If
  73.  
  74.     if GetInstalledProductREG("Microsoft Office 2007") = "present" Then
  75.         O2K7Found = 1
  76.     End If
  77.  
  78.     If O2K7Found = 1 Then
  79.         WriteLog "Microsoft Office 2007 Detected"
  80.         RepairCDCache
  81.         UninstallOffice2007
  82.         RebootFlag = RebootFlag + 1
  83.     Else
  84.         WriteLog "Microsoft Office 2007 Not Detected"
  85.     End If
  86.  
  87. Set wshShell = WScript.CreateObject("WScript.Shell")
  88. Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
  89. Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product")
  90. For Each objSoftware in colSoftware
  91. If objSoftware.Caption = "Microsoft Office Enterprise 2007" Then
  92. OfficeInstalled = True
  93. Exit For
  94. End If
  95. Next
  96. If OfficeInstalled <> True Then
  97. Set oExec = wshShell.Exec ("\\company.local\Public\Applications\Office2007\SETUP.EXE")
  98. Do While oExec.Status = 0
  99. WScript.Sleep 100
  100. Loop
  101. End If
  102.  
  103. Function GetDistroServer
  104. WriteLog "Determining distribution server"
  105. Set shell = CreateObject("WScript.Shell")
  106. Set objFSO = CreateObject("Scripting.FileSystemObject")
  107. Set ipconfig = shell.Exec("%comspec% /c ipconfig")
  108.  
  109. GetDistroServer = "\\dcsb8"
  110.  
  111. deploymentPath = "\\dcsb8"
  112.  
  113. ipConfigResults = lcase(ipconfig.StdOut.ReadAll())
  114. arrIpConfigResults = Split(ipConfigResults, VbCrLf)
  115.  
  116. For Each line In arrIpConfigResults
  117.     line = replace(Trim(line), " ", "")
  118.     'WScript.Echo line
  119.     If InStr(line, "subnetmask") > 0 Then
  120.         arrSubNetMask = Split(Line, ":")
  121.         SubNetMask = arrSubNetMask(1)
  122.     End If
  123.     If InStr(line, "ipaddress") > 0 Then
  124.         arrIPAddress = Split(Line, ":")
  125.         IPAddress = arrIPAddress(1)
  126.     End If
  127.     If InStr(line, "defaultgateway") > 0 Then
  128.         arrGW = Split(Line, ":")
  129.         GW = arrGW(1)
  130.     End If
  131. Next
  132.  
  133. WriteLog "IP Address: " & IPAddress
  134. WriteLog "Subnet Mask: " & SubNetMask
  135. WriteLog "Default Gateway " & GW
  136.  
  137. DeploymentPathFound = 0
  138.  
  139. If InStr(IPAddress, "207.203.") > 0 Then
  140.         DeploymentPathFound = 1
  141.         deploymentPath = "\\dcsb-ex"
  142.         If objFSO.FolderExists(deploymentPath & "\sys\Office-Install\kr_2007\Applications\Office 2007") = False Then
  143.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  144.             DeploymentPathFound = 0
  145.         End If
  146. End If
  147.  
  148. If InStr(IPAddress, "10.20.1.") > 0 Then
  149.         DeploymentPathFound = 1
  150.         deploymentPath = "\\clifton"
  151.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  152.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  153.             DeploymentPathFound = 0
  154.         End If
  155. End If
  156.  
  157. If InStr(IPAddress, "10.20.2.") > 0 Then
  158.         DeploymentPathFound = 1
  159.         deploymentPath = "\\crossroads"
  160.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  161.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  162.             DeploymentPathFound = 0
  163.         End If
  164. End If
  165.  
  166. If InStr(IPAddress, "10.20.3.") > 0 Then
  167.         DeploymentPathFound = 1
  168.         deploymentPath = "\\dcsb8"
  169.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  170.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  171.             DeploymentPathFound = 0
  172.         End If
  173. End If
  174.  
  175. If InStr(IPAddress, "10.20.4.") > 0 Then
  176.         DeploymentPathFound = 1
  177.         deploymentPath = "\\servicecenter"
  178.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  179.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  180.             DeploymentPathFound = 0
  181.         End If
  182. End If
  183.  
  184. If InStr(IPAddress, "10.20.6.") > 0 Then
  185.         DeploymentPathFound = 1
  186.         deploymentPath = "\\north"
  187.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  188.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  189.             DeploymentPathFound = 0
  190.         End If
  191. End If
  192.  
  193. If InStr(IPAddress, "10.20.7.") > 0 Then
  194.         DeploymentPathFound = 1
  195.         deploymentPath = "\\kirkwood"
  196.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  197.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  198.             DeploymentPathFound = 0
  199.         End If
  200. End If
  201.  
  202. If InStr(IPAddress, "10.20.8.") > 0 Then
  203.         DeploymentPathFound = 1
  204.         deploymentPath = "\\enterprises"
  205.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  206.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  207.             DeploymentPathFound = 0
  208.         End If
  209. End If
  210.  
  211. If InStr(IPAddress, "10.20.15.") > 0 Then
  212.         DeploymentPathFound = 1
  213.         deploymentPath = "\\dcsb8"
  214.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  215.             WriteLog "Error - cannot connect to deployment server " & deploymentPath
  216.             DeploymentPathFound = 0
  217.         End If
  218. End If
  219.  
  220. If DeploymentPathFound = 0 Then
  221.         deploymentPath = "\\dcsb-ex"
  222.         WriteLog "Unable to locate a distribution server for this computer!"
  223.         WriteLog "Falling back to \\dcsb-ex"
  224.         If objFSO.FolderExists(deploymentPath & "\sys\office-install") = False Then
  225.             WriteLog "Error - Unable to use fall back server " & deploymentPath
  226.             WriteLog "TERMINATING SCRIPT"
  227.             DeploymentPathFound = 0
  228.             WScript.Quit 1
  229.         End If
  230. End If
  231.  
  232. WriteLog "Distribution Server: " & deploymentPath
  233. GetDistroServer = deploymentPath
  234.  
  235. End Function
  236.  
  237.  
  238. Function RepairCDCache
  239. writeLog "Checking CDCache Value"
  240.  
  241. HKEY_CURRENT_USER = &H80000001
  242. HKEY_LOCAL_MACHINE = &H80000002
  243.  
  244. Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
  245.  
  246. strKeyPath = "SOFTWARE\Microsoft\Office\11.0\Delivery\{90110409-6000-11D3-8CFE-0150048383C9}"
  247. strValueName = "CDCache"
  248. oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
  249. currentCDCache = strValue
  250.  
  251. if trim(currentCDCache) = "2" Then
  252.     writeLog "Changing CDCache value to 0" 
  253.     oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,"0"
  254. end If
  255.  
  256. if trim(currentCDCache) = "0" Then
  257.     writeLog "CDCache value is set to 0" 
  258.  
  259. end If
  260.  
  261. end Function
  262.  
  263. Function SetDefaultDomainLogon(defaultDomain)
  264. WriteLog "Setting default logon domain to, " & defaultDomain
  265.  
  266. HKEY_CURRENT_USER = &H80000001
  267. HKEY_LOCAL_MACHINE = &H80000002
  268.  
  269. Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
  270.  
  271. strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
  272. strValueName = "DefaultDomainName"
  273. oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,defaultDomain
  274.  
  275. End Function
Sep 17 '09 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
here:

Expand|Select|Wrap|Line Numbers
  1. If WScript.Arguments.Count > 0 Then
  2. logonServer = trim(LCase(WScript.Arguments.Item(0)))
  3. If InStr(logonServer, "\\") = 0 Then
  4. logonServer = "\\" & logonServer
  5. 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.
Sep 18 '09 #2

P: 2
Okay, Thanks for your help. I will check for that when I return to the office after the weekend.
Sep 19 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.