我们使用COM对象访问NT服务中的excel电子表格(通过Windows Scripting Host).在Vista之前,这很好用,但从Vista开始,我们收到此错误:
Microsoft Office Excel无法访问文件'c:\ myfiles\test.xls'.有几个可能的原因:
我尝试更改NT服务登录设置以使用我自己的帐户,管理员帐户和本地系统.我查看了本地安全策略,但没有找到任何内容.我花了几天时间搜索Microsoft KB无济于事.
如果脚本是从控制台应用程序执行的,它可以正常工作.该文件打开并处理没有问题.仅在从服务的上下文中执行时才会发生错误.
如果该服务在Windows XP或Server 2003 SP1上运行,它也可以正常工作.只有在Vista上才会失败(我们现在已经收到有关它在Server 2003 SP2中失败的报告)!
代码,它的价值非常简单:
dim xl_app
Set xl_app = CreateObject("Excel.Application")
xl_app.Workbooks.Open mypath,0,1
Run Code Online (Sandbox Code Playgroud)
我怀疑这个人可能遇到了同样的问题: http://bytes.com/forum/thread819740.html
我正在搜索在文件中进行搜索和替换的VBScript(例如1.txt 2.xml).我有文件"1.txt"里面有"临时"这个词,我想把它改成"永久".因为我得到了很多这个文件,所以我需要一个脚本.
每次我尝试编写包含打开txt文件和命令替换的脚本时,它都不会.
我找到了一个脚本,用另一个文件更改了这个文件并在里面进行了更改,但这不是我想要的.
我遇到以下VBS代码时出现问题.它有时只能工作,即使这样它也很快失败.为什么?
Dim Butt
Set Butt = CreateObject("InternetExplorer.application")
Butt.visible = True
Butt2 = InputBox("Put the link to one hat you would like to snipe.", "Hat Selection")
Butt3 = InputBox("Enter the maximum amount of Robux you will spend on this hat.", "Maximum Payment")
Dim Proace
Set Proace = CreateObject("Microsoft.XMLHTTP")
Proace.Open "GET", "http://www.roblox.com", False
Proace.Send
Do
Do While Butt.Busy
WScript.sleep 200
Loop
St00f = CInt(Replace(Mid(St00f, (InStr(St00f, ">R$")+3), 8), "</b>", ""))
If St00f <= CInt(Butt3) Then
Butt.Navigate "javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions(""ctl00$cphRoblox$TabbedInfo$UserSalesTab$lstItemsForResale$ctrl0$lnkBuyNow"",%20"""",%20true,%20"""",%20"""",%20false,%20true))"
Exit Do
End If
Loop
Do …Run Code Online (Sandbox Code Playgroud) 目前我必须处理用VB编写的遗留系统.我对VB和ASP不太满意,所以我决定用JScript编写这个系统的新代码.
但是,这两种语言之间的互操作性存在一些问题:即,当我试图调用在<script language="vbscript">tag中声明的某个函数时,它会因" Object expected "错误而失败(如果页面语言是VBScript),反之亦然.
即,以下代码:
inc.asp
<script language="vbscript" runat="server">
Sub VBTestFunction(Message)
Response.Write "VBTestFunction: " & Message
End Sub
</script>
<script language="javascript" runat="server">
function JSTestFunction(Message) {
Response.Write("JSTestFunction: " + Message);
}
</script>
Run Code Online (Sandbox Code Playgroud)
testjs.asp
<%@ Language="JavaScript" %>
<!-- #include file="inc.asp"-->
<script language="javascript" runat="server">
VBTestFunction("from javascript");
JSTestFunction("from javascript");
</script>
<script language="vbscript" runat="server">
Call VBTestFunction("from vbscript")
Call JSTestFunction("from vbscript")
</script>
Run Code Online (Sandbox Code Playgroud)
失败,出现以下错误:
VBTestFunction: from vbscript
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'JSTestFunction'
/test.asp, line 9
Run Code Online (Sandbox Code Playgroud)
(如果我对特定行进行评论,其他三个语句将正常工作); 将页面语言设置为VBScript
<%@ Language="VBScript" %> …Run Code Online (Sandbox Code Playgroud) 我正在使用Inno Setup开发安装程序,我需要创建一个具有管理员权限的Windows用户,我可以使用此命令正常执行: net localgroup administrators USER /add
但是有一个问题......如果我在非英语Windows上执行此操作,"管理员",组将不存在,又名:如果在pt-br Windows上安装它将被称为"Administradores".
我想知道是否存在一个存储管理组名称的Windows变量.
请注意,使用Inno Setup我可以使用vbs脚本.
从bat文件运行vbs脚本时,有时会在头文件输出文件中写入
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation 1996-2001. Tous droits r‚serv‚s
example: cscript myvbs.vbs file.txt >result.txt
Run Code Online (Sandbox Code Playgroud)
我知道在输出文件上做了更多+2,我可以忽略它.毫无疑问,我想知道是否有可能以不同的方式做到这一点.
先感谢您
我正在尝试使用getref从与测试关联的函数库中调用函数.我的代码 -
在行动1
str = "sample"
msg = "hi"
x = GetRef("Function_"&str)(msg)
msgbox x
Run Code Online (Sandbox Code Playgroud)
在函数库中,
Function Function_sample(strMsg)
Function_sample = strMsg
End Function
Run Code Online (Sandbox Code Playgroud)
我收到了错误 -
"无效的过程调用或参数."
但是如果函数放在同一个动作中,它可以正常工作.如何调用函数库中的函数(带参数),从变量中获取函数名?
我有一个脚本打开excel文件并运行宏,然后退出该文件.由于文件处于只读模式,并且脚本对文件进行临时更改,因此当脚本调用myExcelWorker.Quit()excel询问我是否要保存更改时,必须单击"否".有没有办法退出程序并跳过此框?
' Create a WshShell to get the current directory
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
' Create an Excel instance
Dim myExcelWorker
Set myExcelWorker = CreateObject("Excel.Application")
myExcelWorker.Visible = True
' Tell Excel what the current working directory is
' (otherwise it can't find the files)
Dim strSaveDefaultPath
Dim strPath
strSaveDefaultPath = myExcelWorker.DefaultFilePath
strPath = WshShell.CurrentDirectory
myExcelWorker.DefaultFilePath = strPath
' Open the Workbook specified on the command-line
Dim oWorkBook
Dim strWorkerWB
strWorkerWB = strPath & "\BugHistogram_v2.xlsm"
Set oWorkBook …Run Code Online (Sandbox Code Playgroud) 我有3个脚本,其中所有脚本必须以正确的顺序重复运行.
下面的脚本是第3个脚本.每当我运行它时,它都会以"输入文件末尾"错误结束.我已经尝试了几次修改,它总是以这种方式结束.
我对第三个脚本的想法是第二个文件的Differences.txt输出仍然需要从第一个脚本运行进程,所以我只是删除原始输入文件并将其重命名为新的输出文件.但是,我还必须跟踪已经完成的过程,因此我必须将它们列出/附加到另一个文本文件.
在此先感谢您的帮助.
Option Explicit
Dim objFso
Dim Fso
Dim firstfile,secondfile,file,fileText
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("Machines.ini") Then objFSO.DeleteFile("Machines.ini")
Set Fso = WScript.CreateObject("Scripting.FileSystemObject")
Fso.MoveFile "Differences.txt", "Machines.ini"
firstfile="Notified.txt"
secondfile="Notified-all.txt"
Set fso=CreateObject("Scripting.FileSystemObject")
Set file=fso.OpenTextFile(firstfile)
fileText = fileText & file.ReadAll() & vbCrLf
file.Close
Set file=fso.OpenTextFile(secondfile)
fileText=filetext & file.ReadAll()
file.Close
set file=fso.CreateTextFile(secondfile,true)
file.Write fileText
file.close
Run Code Online (Sandbox Code Playgroud) vbscript ×10
.net ×1
asp-classic ×1
batch-file ×1
c# ×1
com ×1
excel ×1
excel-vba ×1
inno-setup ×1
jscript ×1
qtp ×1
vba ×1
windows ×1