.vbs中的对象以什么顺序销毁?
也就是说,给定这些全局变量:
Set x = New Xxx
Set y = New Yyy
Run Code Online (Sandbox Code Playgroud)
我对以下任何一个问题的答案感兴趣.
对于.VBS中实现的类的实例,将以什么顺序Class_Terminate调用?粗略的戳戳建议创造的顺序(而不是逆序!),但这有保证吗?
编辑:我知道Class_Terminate将在释放对象的最后一次引用时调用.我的意思是:x和y的发布顺序是什么,是否有保证?为简单起见,假设x和y是对其各自对象的唯一引用.
对象的类型是否重要?例如,如果我在.VBS中实现的类与其他COM对象混合在一起,例如Scripting.FileSystemObject.
编辑:我知道COM库可能会设置自己的内部循环引用,脚本主机引擎一无所知; 我有兴趣探索可能影响第一个问题答案的内容.
WScript.Quit?(在后一种情况下,似乎Class_Terminate在退出之前仍然会调用任何未完成的对象,但这些可能会导致报告错误).我可以凭经验找到其中一些问题的答案,但我对它们中的任何一个是否得到保证 /记录感兴趣.
即使你只知道一些答案 - 或进一步的相关问题,请发帖.
我有几个使用FileSystemObject的过程.我发现这很方便.
问题:将一个现有的FileSystemObject实例从"主"过程传递给这些其他过程作为参数是否合理,而不是让每个过程创建自己的FileSystemObject实例?
示例:以任何方式更好地执行此操作:
Sub MainSub()
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Call OtherSub(FSO, myargs)
' call other subs and functions that use FileSystemObject
End Sub
Sub OtherSub(FSO, myargs)
' Do stuff with FSO
' call other subs and functions that use FileSystemObject
End Sub
Run Code Online (Sandbox Code Playgroud)
我至少看过一个程序员,而不是以下,这是我通常做的事情:
Sub MainSub()
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Call OtherSub(myargs)
' call other subs and functions that use FileSystemObject
End Sub
Sub OtherSub(myargs)
Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
Call OtherSub(myargs)
' …Run Code Online (Sandbox Code Playgroud) 我在http://www.hmailserver.com/documentation/latest/?page=com_example_account_create下面提供了以下代码作为hMailServer的DCOM API提供的代码以下脚本正常工作.它没有任何参考.在安装hMailServer之后,运行以下代码可以创建一个帐户.现在,我在C#中需要相同的东西.他们没有为我提供任何C#我用Google搜索的库,但我没有相关的结果是下面的代码,但根据hMailServer API,他们说你可以将下面的脚本转换成你想要的任何语言.但是怎么样?我甚至不知道如何开始写第一行.有人请帮帮我.
Dim obApp
Set obApp = CreateObject("hMailServer.Application")
' Authenticate. Without doing this, we won't have permission
' to change any server settings or add any objects to the
' installation.
Call obApp.Authenticate("Administrator", "your-main-hmailserver-password")
' Locate the domain we want to add the account to
Dim obDomain
Set obDomain = obApp.Domains.ItemByName("example.com")
Dim obAccount
Set obAccount = obDomain.Accounts.Add
' Set the account properties
obAccount.Address = "account@example.com"
obAccount.Password = "secret"
obAccount.Active = True
obAccount.MaxSize = 100 ' Allow max …Run Code Online (Sandbox Code Playgroud) 我正在编写一个VB脚本来更新网络上的一些文件.在开始之前,我想知道是否有任何文件被锁定.在我真正做任何更新之前,我想这样做.
我知道当我尝试更换文件时,如果文件被锁定,我可以处理错误,但我真的想知道在开始更新任何文件之前是否有任何文件被锁定.
有没有办法看到使用VBS锁定文件(除了尝试替换它)?
有没有办法在vbscript中为每个类创建一个变量?
如果不是,最好的方法是什么呢?前缀在类旁边声明的全局变量?
还有一种方法来声明静态/类方法(对于静态构造函数)或我是否强制为函数添加前缀?
我无法让vbscript逐行读取文本.这是代码应该执行的步骤:
folder.txt包含的示例:
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\test.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[12CUT] _____ (Gakkou no Kaidan) [518382]\test.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[2____] _____!__CD__________ [521206]\test.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[Ability] _____________________ [514182]\test.txt
Run Code Online (Sandbox Code Playgroud)
folder-list.txt包含的示例:
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\dirlist.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[12CUT] _____ (Gakkou no Kaidan) [518382]\dirlist.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[2____] _____!__CD__________ [521206]\dirlist.txt
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[Ability] _____________________ [514182]\dirlist.txt
Run Code Online (Sandbox Code Playgroud)
每个dirlist.txt包含的示例
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ ___- [525067]\00.jpg
C:\Documents and Settings\Administrator\Desktop\ArtistCG\[ Go! Go! Heaven!!]_____________25 -______ …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式向我的Windows 8搜索索引添加位置(范围).经过一些谷歌搜索,我发现[这里]的代码:
Set objISAdm = CreateObject("Microsoft.ISAdm")
Set objCatalog = objISAdm. GetCatalogByName("MyCatatlog")
Set objScope= objCatalog.AddScope("C:\myfiles",False)
objScope.Alias = "MyCatalogScope"
Run Code Online (Sandbox Code Playgroud)
不幸的是,800A01AD错误提示无法创建对象'Microsoft.ISAdm'.进一步挖掘,似乎上面的代码不适用于Windows 8上的较新版Windows Search.
有谁知道如何使用vb脚本或从命令行?据推测,在Windows 7下工作的东西也适用于Windows 8.
我有一个非常直截了当的问题.
我正在使用此正则表达式来匹配实例{somestring}.
\{{1}(\w+?)\}{1}
Run Code Online (Sandbox Code Playgroud)
问题是,我需要它忽略的情况下{{somestring}},当然,这是相匹配的内部{somestring}在{{somestring}}.
知道如何调整表达式以跳过任何类似的东西{{somestring}}吗?
我正在使用vbscript的正则表达式引擎.
我正在寻找与字典对象项相关的解决方法
Dim a, d 'Create some variables
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens" 'is possible I know
d.Add "a", "Athens","India","Paris" ' Is this Possible under same Key?
Run Code Online (Sandbox Code Playgroud)
描述快照:( 更新)
Manger ID EMPID EMPID EMPID EMPID ......
11 12 10
15 10
20 22 45 46
40
Run Code Online (Sandbox Code Playgroud)
如何使用字典对象实现上表?给我一些想法.
谢谢,
我想制作一个小的VBS脚本,告诉用户文件是否在使用中.我有一个文件,如果这个文件正在使用VBS应该给我一个消息,该文件正在使用中.如果任何进程未使用该文件,VBS应该向我发出该文件未被使用的消息.我试过这个,但没有任何作用.
vbscript ×10
c# ×1
class-method ×1
com ×1
destructor ×1
file ×1
oop ×1
powershell ×1
regex ×1
vba ×1
windows ×1
wsh ×1