我正在开发一个 VBS 脚本来通过 Outlook 自动发送电子邮件。每次脚本运行时,文件夹中都会有 2 个文件,我需要它附加名称中包含“Formatted”的文件。我尝试使用 Dir 方法,这样我就可以通配符文件路径,但它会抛出一个错误,指出 Dir是一个未定义的变量。
这是我的代码:
Option Explicit
Const olMailItem = 0
Sub SendBasicEmail()
Dim olApp: Set olApp = CreateObject("Outlook.Application")
Dim olEmail: Set olEmail = olApp.CreateItem(olMailItem)
Dim strLocation
strLocation = Dir("C:\Users\MChambers\Desktop\Pricing Reports\Pricing_Report_*Formatted.xslx")
If strLocation <> "" Then
With olEmail
.SentOnBehalfOfName = "generic"
.Attachments.Add (strLocation)
.To = "myemail"
.Subject = "Subject"
.send
End With
End If
End Sub
Run Code Online (Sandbox Code Playgroud) 我需要在IIS 6.0上编写应用程序池和网站的脚本.我已经能够使用adsutil.vbs和iisweb.vbs创建这些,但不知道如何将我刚刚创建的站点的ASP.NET版本设置为2.0.50727.0.
理想情况下,我想adsutil.vbs更新元数据库.我该怎么做呢?
.=连接字符串时ASP的等价于什么?我指的是asp NOT asp.net.
我的意思是指明我在for循环中.所以我想知道.=(在php中)不等于标准串联的等价物.
例:
For Each Item In Request.Form
If (Item = "service") then
For x=1 To Request.Form(item).Count
service = "&service="&Request.Form(Item)(x)
Next
End If
Next
Run Code Online (Sandbox Code Playgroud) 如果答案很明显,请原谅我,因为我编写了vbscript已经很长时间了.
在vbscript中调用函数时是否有使用Call的优点?
例如:
SomeFunction param1, param2
Run Code Online (Sandbox Code Playgroud)
VS
Call SomeFunction (param1, param2)
Run Code Online (Sandbox Code Playgroud) 我希望此脚本替换同一文本文件中的两个值而不是一个.但是,如果我取消注释第12行,它会破坏脚本.我是否必须将其转换为循环,还是可以进行多次替换?
Sub ReplaceTxt()
'Writes values we got earlier to our unattend file '
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strSIFpath, ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "***COMPNAME***", strCompname)
' strNewText = Replace(strText, "***Winkey***", strPoductkey) '
Set objFile = objFSO.OpenTextFile("C:\$WIN_NT$.~BT\winnt.sif", ForWriting)
objFile.WriteLine strNewText
objFile.Close
End Sub
Run Code Online (Sandbox Code Playgroud) 我在QTP中使用VBscript,我有点困惑:
Browser("name:=.*") //works
Run Code Online (Sandbox Code Playgroud)
为什么Browser("name:=*")不起作用?为什么会有.角色?
谢谢!
要在DB上使用Filestream,必须完成3个步骤:
1)启用服务器/实例级别
2)sp_configure在数据库级别启用()
3)创建一个varbinary(max)支持文件流的字段
使用T-SQL轻松完成(2)和(3)
(1)可以从SQL Server配置管理器手动完成,基本上我需要选中所有3个复选框:

(来源:sql-server-performance.com)
但是如何使其自动化?
我发现了这个“在VBScript中使用文件流”的技巧,除了使用VBScripts之外,还有另一种方法吗?可能只有2008R2才有可能吗?
万一VBScript是唯一的解决方案,可能有哪些弊端?
我正在尝试用VBScript/ASP编写一个多人tic-tac-toe游戏.
以下是发生上述错误的代码:
For x = 1 To 3
If AllEqual(arr(x,1), arr(x,1), arr(x,1)) Then
If arr(x,1) = GetText(currentplayer) Then
bWinner = currentplayer
Else If arr(x,1) = GetText(0) Then
'nothing to do
Else
If GetNumber(arr(x,1)) <> currentplayer Then
bWinner = GetNumber(arr(x,1))
End If
End If
End If
Next
Run Code Online (Sandbox Code Playgroud)
这是错误消息的输出:
/iTicTic/play.asp,第82行
Next ^
我在这做错了什么?
谢谢!伊凡
编辑:完整代码:http://pastebin.com/BcR4HZ4a
我有一个带有此条目的xml文件DataConfiguration.xml
<DataSource>
<localdata>
<add context="Localization">
<parameter name="timeout" type="int" defaultvalue="60"/>
<parameter name="address" type="string" defaultvalue="192.168.9.45" />
<parameter name="port" type="int" defaultvalue="6789"/>
</add>
</localdata>
</DataSource>
Run Code Online (Sandbox Code Playgroud)
我需要在"localdata"中添加另一个条目,这样就可以了
<DataSource>
<localdata>
<add context="Localization">
<parameter name="timeout" type="int" defaultvalue="60"/>
<parameter name="address" type="string" defaultvalue="192.168.9.45" />
<parameter name="port" type="int" defaultvalue="6789"/>
</add>
<add context="General">
<parameter name="timeout" type="int" defaultvalue="60"/>
<parameter name="address" type="string" defaultvalue="192.168.9.478" />
<parameter name="port" type="int" defaultvalue="5674"/>
</add>
</localdata>
</DataSource>
Run Code Online (Sandbox Code Playgroud)
我如何在vbscript中添加它?
我的当前代码
'created xml file object
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.preserveWhiteSpace= True
xmlDoc.load("DataConfiguration.xml")
Dim entry
entry = "<add context=""General"">" …Run Code Online (Sandbox Code Playgroud) 我是RegEx的新手.任何人都可以告诉我是否可以确定文件名中是否有特定的单词(如电子邮件或游戏).
RegEx是最好的发现方式吗?如果不是最好(简单)的方法是什么?
任何代码示例将不胜感激.
问候