vbs语法错误:预期为800A03EE')' [英] vbs syntax error: 800A03EE ')' expected

查看:298
本文介绍了vbs语法错误:预期为800A03EE')'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在名为"addcurrentkey.vbs"的文件中执行此操作 但它在第1行中应显示)".字符38.

I try to execute this in a file called 'addcurrentkey.vbs' But it says ')' is expected in row 1. Character 38.

我尝试了本教程: http://www.codeproject.com/Articles/16569/Autorun-Applications

为什么我不能执行.vbs文件?

Why can't I execute a .vbs file?

Private Sub AddCurrentKey(ByVal name As String, ByVal path As String)
Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) 
key.SetValue(name, path) 
End Sub 

推荐答案

您发布的代码可能是用VB.net(或VBA)编写的.您想将代码作为VBScript运行,它不支持类型化的参数和变量.它还不提供您要使用的注册表对象.从此更改过程:

The code you posted is probably written in VB.net (or perhaps VBA). You are tying to run the code as VBScript, which does not support typed parameters and variables. It also doesn't provide the registry object you're trying to use. Change the procedure from this:

Private Sub AddCurrentKey(ByVal name As String, ByVal path As String)
  Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True) 
  key.SetValue(name, path) 
End Sub

对此:

Private Sub AddCurrentKey(ByVal name, ByVal path)
  Dim key : key = "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
  CreateObject("WScript.Shell").RegWrite key & "\" & name, path
End Sub

问题将消失.

这篇关于vbs语法错误:预期为800A03EE')'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆