• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

VB Script Error

I have a software application that requires that i make a startup script with the code below in it. However, i am getting this error message upon login.

Osmgr.vbs  script
Line 4 char 1 error  expected statement
Code 800A0400
Source Microsoft VBScript compilation error

Can anyone help me out? I copied this from the documentation, i dont know anything about VB, so if there is any issue with the way that it is formatted, i wouldnt notice it.

Thanks!
Set WSHShell = WScript.CreateObject("WScript.Shell")
'To Enable Remote DCOM in the computer
WshShell.RegWrite
"HKLM\SOFTWARE\Microsoft\Ole\EnableDCOM","Y","REG_SZ"
'To Set Authentication Level to Connect
WshShell.RegWrite
"HKLM\SOFTWARE\Microsoft\Ole\LegacyAuthenticationLevel",2,
"REG_DWORD"
'To Set Impersonation level to Impersonate
WshShell.RegWrite
"HKLM\SOFTWARE\Microsoft\Ole\LegacyImpersonationLevel",3,
"REG_DWORD"

Open in new window

0
jaredwhamilton
Asked:
jaredwhamilton
  • 3
  • 3
  • 2
2 Solutions
 
davewlCommented:
You need to take out the carriage returns after each wshShell.Regwrite.

Should behave then.



Set WSHShell = WScript.CreateObject("WScript.Shell")
'To Enable Remote DCOM in the computer
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\EnableDCOM","Y","REG_SZ"
'To Set Authentication Level to Connect
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\LegacyAuthenticationLevel",2,"REG_DWORD"
'To Set Impersonation level to Impersonate
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\LegacyImpersonationLevel",3,"REG_DWORD"

Open in new window

0
 
Jammer59Commented:
When you copied from the documentation, you copied verbatim.  It appears some code which should be one line are two.  For example, Lines 3 and 4 are actually one line of code but they appear as two in your listing. Lines 6, 7 and 8 are actually one line of code and lines 10, 11 and 12 are actually one line of code.
 
I am attaching a Code Snippet which will show what I think the actual code should look like.

Set WSHShell = WScript.CreateObject("WScript.Shell")
 
'To Enable Remote DCOM in the computer
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\EnableDCOM","Y","REG_SZ"
 
'To Set Authentication Level to Connect
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\LegacyAuthenticationLevel",2,"REG_DWORD"
 
'To Set Impersonation level to Impersonate
WshShell.RegWrite "HKLM\SOFTWARE\Microsoft\Ole\LegacyImpersonationLevel",3,"REG_DWORD"

Open in new window

0
 
jaredwhamiltonAuthor Commented:
Both resulted in another error.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
Jammer59Commented:
It worked for me in Windows XP.  
Questions:
(1) What O/S are you using?
(2) If you open the registry, did any of the registry settings get updated?  If so, which ones.
(3) Assuming you named the script something like updatereg.vbs.   Are you executing the script by typing in cscript updatereg.vbs?
 
0
 
davewlCommented:
And what was the other error?  Are you logged in as an account with admin rights?
0
 
jaredwhamiltonAuthor Commented:
Which one worked? This script is to run whenever anyone logs on. This is how the documentation said to make it. I have it in the default domain policy, set as a logon script for any user.
0
 
Jammer59Commented:
The code snippet in my comment from 02.10.2009 at 4:53 PM worked for me.  
Have you looked at the error logs on the user machine to verify you are not having a permissions issue with the script?
0
 
jaredwhamiltonAuthor Commented:
Good Job guys. We called the vendor to ask them what was up, apparently the script was designed for networks that do not have group policy available to them (Workgroups). They did not state that in the documentation. Thanks for your help. I split the points, because i think both solutions are correct. Thanks again!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now