在我的代码段中,当我编写文件名脚本时,它在以下行给我一个权限被拒绝:
Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, ForAppending, True)
Run Code Online (Sandbox Code Playgroud)
这是脚本
'output log info
Function OutputToLog (strToAdd)
Dim strDirectory,strFile,strText, objFile,objFolder,objTextFile,objFSO
strDirectory = "c:\eNet"
strFile = "\weeklydel.bat"
'strText = "Book Another Holiday"
strText = strToAdd
' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
'WScript.Echo "Just created " & strDirectory
End If
If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else …Run Code Online (Sandbox Code Playgroud) 当你像x = myfunc(a,b,,d) 第三个参数一样调用函数时?它是空的吗?空值?没有?
我的功能有问题,比方说,
function myfunc(p1, p2, p3, p4)
if p3 <> "" then whatever
end function
Run Code Online (Sandbox Code Playgroud)
给了我一个可怕的 type mismatch
PS我正在尝试用vbscript函数替换COM对象,并且对那些没有问题的COM对象进行了那些空参数调用,但是vbscript不喜欢它们.我不能改变调用,只有函数,所以我需要以某种方式处理空参数,只是不知道如何(尝试isnull没有运气,也是没有运气,并is nothing给我一个object required错误)
可以使用VBScript转义来转发帖子(application/x-www-form-urlencoded)或多部分帖子吗?它是否相当于PHP的urlencode?
我使用"ATL简单对象"向导在C++中使用ATL构建了一个COM服务器DLL.我关注了微软的ATLDLLCOMServer示例.一切都很好,除了一件事:我没有在VBScript中收到COM事件.我确实收到了C#中的事件.我在VBScript中使用早期基于MFC的实现中的事件作为ActiveX控件.
我的控件定义如下:
class ATL_NO_VTABLE CSetACLCOMServer :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>,
public IConnectionPointContainerImpl<CSetACLCOMServer>,
public CProxy_ISetACLCOMServerEvents<CSetACLCOMServer>,
public IDispatchImpl<ISetACLCOMServer, &IID_ISetACLCOMServer, &LIBID_SetACLCOMLibrary, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IProvideClassInfo2Impl<&CLSID_SetACLCOMServer, &DIID__ISetACLCOMServerEvents, &LIBID_SetACLCOMLibrary> /* Required for event support in VBS */
{
public:
BEGIN_COM_MAP(CSetACLCOMServer)
COM_INTERFACE_ENTRY(ISetACLCOMServer)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()
BEGIN_CONNECTION_POINT_MAP(CSetACLCOMServer)
CONNECTION_POINT_ENTRY(__uuidof(_ISetACLCOMServerEvents))
END_CONNECTION_POINT_MAP()
[...]
Run Code Online (Sandbox Code Playgroud)
在VBScript中我使用COM对象,如下所示:
set objSetACL = WScript.CreateObject("SetACL.SetACL", "SetACL_")
' Catch and print messages from the SetACL COM server which are passed (fired) as events.
' The name postfix …Run Code Online (Sandbox Code Playgroud) 我有一个客户提供的以下XML,我需要从中提取以下项目:
<CustomerProductName><ProductName> <ProductAssetName>将每个<CustomerProducts>部分视为单独的订单.
我可以<CustomerProducts>在<CustomerProductName>没有问题的情况下提取并迭代,并迭代每个部分中的值.
但我无法看到我如何得到它下面的值.如果有人可以给我一些关于如何实现这一点的指示我会感激不尽,因为我已经尝试了一天多了.
基本代码在XML下面
<?xml version="1.0"?>
<Products_Root>
<Products_IPN VendorID="11344" >
<CustomerProducts CustomerProductName="Test" ProductCount="7">
<Products ProductType="BOOK" ProductName="Donald" >
<ProductComponents ProductAssetName="Donald.pdf" />
<ProductSpecs SpecClass="MEASUREMENT" SpecType="MARGINS" SpecValue="PER FILE"/>
<ProductSpecs SpecClass="OPERATION" SpecType="BIND" SpecValue="SADDLE"/>
</Products>
<Products ProductType="BOOK" ProductName="Duck">
<ProductComponents ProductAssetName="Duck.pdf"/>
<ProductSpecs SpecClass="MEASUREMENT" SpecType="MARGINS" SpecValue="PER FILE"/>
</Products>
</CustomerProducts>
<CustomerProducts CustomerProductName="Test2" ProductCount="2">
<Products ProductType="BOOK" ProductName="Micky">
<ProductComponents ProductAssetName="Mouse.pdf" />
<ProductComponents ProductAssetName="Mouse.pdf" />
<ProductSpecs SpecClass="MEASUREMENT" SpecType="MARGINS" SpecValue="PER FILE"/>
</Products>
<CustomerProductSpecs SpecClass="OPERATION" SpecType="KITTING" SpecValue="SHRINKWRAP KIT"/>
</CustomerProducts>
<CustomerProducts CustomerProductName="Test3" ProductCount="6">
<Products …Run Code Online (Sandbox Code Playgroud) 在下面的命令的帮助下,我能够清除单元格的内容,但不能清除它们的背景颜色.如何清除和设置范围内单元格的背景颜色?
ob9.Range(ob9.Cells(1,StartCol),ob9.Cells(1,maxcolumn)).ClearContents
Run Code Online (Sandbox Code Playgroud)
编辑
我试过以下:
CountFill = objExcel1.Application.WorksheetFunction.CountA(ob9.Rows(1))
CountBlnk = objExcel1.Application.WorksheetFunction.CountBlank(ob9.Rows(1))
TotalColumn= CountBlnk + CountFill
ob9.Range(ob9.Cells(1,CountFill + 1 ),ob9.Cells(1,TotalColumn)).Interior.ColorIndex(-4142) '= xlColorIndexNone
Run Code Online (Sandbox Code Playgroud)
可以一行完成吗?
谢谢
我想检查进程是否正在运行?如果进程没有运行,那么我执行它(在这个例子中我带了进程名称= calc.exe的计算器)我启动了批处理脚本,但我有一个语法问题我相信!
@echo off
Set MyProcess=calc.exe
echo %MyProcess%
pause
for /f "tokens=1" %%i In ('tasklist /NH /FI "imagename eq %MyProcess%"') do set ff=%%i
echo %ff%
If /i %ff%==%MyProcess% (Echo %ff% est en cours d^'execution) Else (Start %MyProcess%)
pause
Run Code Online (Sandbox Code Playgroud) 添加到2014年6月19日发布
谢谢邦德.既然你有IE9,我感谢你的测试.希望如果那里的人有IE 10,他们也会测试它.没有任何意义,为什么在IE 11引擎下你只能运行兼容性ie8.
我创建了这个微小的,非常小的HTA,以便发布它,希望我能找到我所缺少的东西.
我的系统是带有IE 11的Win7 Pro 64位.
当我将元标记设置为:
<meta http-equiv="x-ua-compatible" content="ie=8">
Run Code Online (Sandbox Code Playgroud)
HTA运行时非常敏锐.没问题.但当我把它改为:
<meta http-equiv="x-ua-compatible" content="ie=9">
Run Code Online (Sandbox Code Playgroud)
它运行得不那么好.
现在......我知道IE 11和VBScript之间有一个大家庭爆发.VBscript被赶出了家门.IE 11拒绝再与它通信.所以我可以理解为什么将它设置为content ="ie = edge"是行不通的.但是为什么将它设置为content ="ie = 9"时它不起作用?
<!DOCTYPE html>
<head>
<meta http-equiv="x-ua-compatible" content="ie=8">
<hta:application
applicationname="Hmmmmmm"
singleinstance="yes"
id="oHTA"
>
<title>Huh? What?</title>
<script language="VBScript">
Option Explicit
Dim objFSO,file
Sub Window_OnUnLoad
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set file=objFSO.OpenTextFile("c:\temp\submit.txt",2,True)
file.Write oHTA.document.getElementById("aa").value
file.Close
Set objFSO=Nothing
Set file=Nothing
End Sub
Sub Window_OnLoad
window.ResizeTo 240,130
End Sub
Function Form_OnSubmit()
window.Close
Form_OnSubmit=False
End Function
</script>
</head>
<body style="margin:30px;">
<form id="form" action=""> …Run Code Online (Sandbox Code Playgroud) 如何从启动QTP测试的.vbs文件中获取测试参数?我可以从.vbs文件运行我的测试,没有任何输入参数就好了,但我似乎找不到从文件中获取参数到测试的方法.
这是我到目前为止:
Set qtp = CreateObject("QuickTest.Application")
'Launch QTP
qtp.Launch
'Set QTP visible
qtp.Visible = True
'Run Mode - Fast
qtp.Options.Run.RunMode = "Fast"
'View Results - True
qtp.Options.Run.ViewResults = True
'Open the test
qtp.open "C:\MY\TEST", True
Set test = qtp.Test
Set params = test.ParameterDefinitions.GetParameters()
parameter1 = "par1"
parameter2 = "par2"
params.Item(par1).Value = "This is my first parameter"
params.Item(par2).Value = "This is my second parameter"
Set qtpResultsLocation = CreateObject("QuickTest.RunResultsOptions")
qtpResultsLocation.ResultsLocation = "C:\SOME\RESULTS\FOLDER"
test.Run qtpResultsLocation
test.Close
Msgbox("Closed test.. closing application")
qtp.quit
Run Code Online (Sandbox Code Playgroud)
我觉得需要某种形式test.ParameterDefinitions.SetParameters() …
假设我有一组数字23,56,128,567,我必须应用一个条件逻辑,如果myData上面一组数字中存在一个变量,那么只有我继续,否则我不会.
抱歉,必须查看一些遗留代码,并且不确定如何在VBScript中执行此操作.