我如何使用 vbscript 检查 C:\Temp\CAD_Kunde.txt 中的 txt 文件是否存在,如果不存在,则应将其创建为空。
编辑:我收到错误(当我使用此命令时,第 11 行字符 1 上的预期语句:
<SCRIPT Language="VBScript">
Sub Window_OnLoad
//Line 11 is the one below:
Option Explicit
Dim oFSO, oTxtFile
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists("C:\Temp\CAD_Kunde.txt") then
Msgbox "File Exist"
Else
Set oTxtFile = oFSO.CreateTextFile("C:\Temp\CAD_Kunde.txt")
Msgbox "File Created"
End If
End Sub
</script>
Run Code Online (Sandbox Code Playgroud) 我需要将数据从一个进程发送到另一个进程。限制条件:
发送方进程是非常昂贵的调用。需要使用 vbscipt 来完成。对于Sender进程来说,这个数据传输是一项额外的工作。它应该不会受到这个特性的太大影响。4-5 分钟内,发送方进程中大约有 1000 个线程。
更快的IPC很重要。如果能异步完成那就更好了。我读到了有关命名管道的信息。是否可以使用 vbscript 打开命名管道。考虑到上述限制,还有其他可能的方法吗?
我想使用 VBS 读取注册表以列出服务器上的一些信息,包括驱动程序。
视频BS:
REM Run this file with the following command:
REM cscript drivers.vbs | clip
WScript.Echo "------------------------------------------------"
Const HKEY_LOCAL_MACHINE = &H80000002
'Get Server Name
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName
WScript.Echo "Computer Name: " & strComputerName
'Get Driver Names
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers"
objRegistry.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes
For i = 0 to UBound(arrValueNames)
strValueName = arrValueNames(i)
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Wscript.Echo arrValueNames(i) & " -- …Run Code Online (Sandbox Code Playgroud) 我有一组字符串,其中可能有也可能没有特殊字符。\n示例:
\n\nWindows Live Fot\xc2\xa2t\xc2\xa0r\nGaler\xc2\xa1a fotogr\xc2\xa0fica de Windows Live\nWindows Live Maker\nRun Code Online (Sandbox Code Playgroud)\n\n我想做的是:
\n\n\n\n\n\n
\n- 检查整个字符串中是否包含特殊字符
\n- 如果是,请将这些字符替换为“?”
\n
自从我成为 vb 脚本新手以来,我还没有尝试过任何东西。
\n我正在尝试使用 VBScript 移动鼠标。我尝试使用 Sendkeys"{CLICK LEFT , x , y}"和 Sendkeys"{MOVETO, 10 , 20}"但它不起作用我也尝试使用 MouseKeys,所以我可以用键盘移动它,因此用于Sendkeys激活它,但它也不起作用(鼠标键数字键盘不移动鼠标) 。我已经尝试了我所知道的一切以及我可以在其他地方研究的一切,所以现在我希望你们中的一个人能为我回答这个问题。谢谢
我正在尝试找到如何使用其标题关闭进程。
我找到了命令:
taskkill /fi "WINDOWTITLE eq the_title_of_the_windows"
Run Code Online (Sandbox Code Playgroud)
而且效果很好。
当我尝试时:
oShell.Run "taskkill /fi "WINDOWTITLE eq the_title_of_the_windows"", , True
Run Code Online (Sandbox Code Playgroud)
我收到错误并且无法编译。
关于如何在这一行中使用符号“有什么想法吗?
我想使用 VBScript 获取一个数字并将其转换为小写a-z字母。
例如:
1转换为a2转换为b27转换为aa28转换为ab特别是在转换为 2 个字母的单元格名称时,我在转换 26 之后的数字时遇到问题。(aa、ab、ac等)
在我们的环境中,我们使用的两种主要脚本语言是 VBScript/WScript 和 PowerShell。我们的 PowerShell 设置为所有脚本都必须经过数字签名。在 PowerShell ISE 内部,我们添加了一个菜单项,用于保存当前工作脚本并对其进行数字签名。目前,我们对 VBS/Wscript 使用不同的编辑器。VSCode 中有没有办法允许我们在环境中运行一个函数来对当前的 PowerShell 脚本进行数字签名?
我正在尝试使用我在网上找到的对象属性(即 Id)函数对字典进行排序,但在这一行For Each i In dict我收到此错误消息 Microsoft VBScript 运行时错误:对象不支持此属性或方法。我已经尝试过,For Each i In dict.Items但我收到与“dict.Items”相同的错误消息我使用的是旧版本的 VBScript,因此它不具有以下功能dict.Count
VBScript 类:
Class TestClass
Public ID
Public TestText
Private Sub Class_Initialize
TestText = ""
End Sub
End Class
Set gDic = CreateObject("Scripting.Dictionary")
For i = 1 to 5
Set temp = new TestClass
temp.ID = i
temp.TestText = "Test" & i
gDic.Add i,temp
Next
Set NewDic = SortDict(gDic)
msgbox NewDic.Items()(1).TestText
Run Code Online (Sandbox Code Playgroud)
排序功能:
Function SortDict(ByVal dict)
Dim i, j, temp
For Each i …Run Code Online (Sandbox Code Playgroud) Fairly new to VBscript and VBA... hoping for some help and that it's an easy answer...
I'm calling a Macro / Function in Excel VBA from VBscript. The call to the Function should return a number. Using VBA debug in Excel, the function appears to work properly (in this example, it displays a value of 1), but when I call the Macro / Function and attempt to echo the value in VBscript it shows as "Empty".
How can I get …