如果周三的脚本是计算机运行的,我希望它在一个网络地图中创建一个%computername*.txt文件。在批处理脚本中,我可以用%computername%.txt对它进行处理,对于VBS脚本,我可以使用什么代码?
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
If DatePart("W",Date) = 4 Then
'Today is Wednesday, so run the virus scan
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("\\server\Avast Scan Log\%COMPUTERNAME%.txt")
WshShell.Run """C:\Program Files\Alwil Software\Avast4\aswcmd"" M: /m /*", , True
End If 发布于 2012-03-09 14:40:31
>> WScript.Echo CreateObject("WScript.Shell").ExpandEnvironmentStrings("%COMPUTERNAME%")
>>
WINXPSP3
>> WScript.Echo CreateObject("WScript.Network").Computername
>>
WINXPSP3发布于 2012-03-09 21:41:35
使用WshNetwork对象获得建议的计算机名称。它看起来像这样。
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
If DatePart("W",Date) = 4 Then
'Today is Wednesday, so run the virus scan
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("\\server\Avast Scan Log\" & strComputer & ".txt")
WshShell.Run """C:\Program Files\Alwil Software\Avast4\aswcmd"" M: /m /*", , True
End Ifhttps://stackoverflow.com/questions/9635600
复制相似问题