VBScript(Microsoft Visual Basic Script Editon).,微软公司可视化BASIC脚本版)。正如其字面所透露的信息,VBS(VBScript的进一步简写)是基于Visual Basic的脚本语言。
进一步解释一下,Microsoft Visual Basic是微软公司出品的一套可视化编程工具,语法基于Basic. 脚本语言,就是不编译成二进制文件, 直接由宿主(host)解释源代码并执行,简单点说就是写的程序不需要编译成.exe, 而是直接给用户发送.vbs的源程序,用户就能执行了。
VBS计算今天日期距离指定日期还有多少天
1、首先需要知道运行bat时隐藏cmd窗口,可以使用vbs文件来做,将vbs文件和bat文件放在一块,如下图所示。
2、看到直接运行bat文件,会打开cmd窗口,如下图所示。
3、编写vbs文件代码,新建一个记事本,然后输入“set ws=WScript.CreateObject("WScript.Shell")ws.Run "d:\runPython.bat",0”代码,第二行代码是bat文件的路径,如下图所示。
4、保存为后缀名为vbs的文件之后,鼠标右键打开,如下图所示。
5、待一会儿,可以看到命令已经执行了,程序运行成功。
谁能帮我做个自动禁用启用网络连接的VBS文件?
你说的两种 都可以用以下代码来解决 代码中一个是用Inputbox输入 一个是直接输入date函数获取今天的日期 ,像 你第二种要求就可以直接将date函数 替换成一个自定义的日期 赋值到变量中 然后再继续使用datediff求得两个日期的间隔
y=cint(inputbox("年"))m=cint(inputbox("月"))
d=cint(inputbox("日"))
msgbox?datediff("d",date,cdate(y?&?"-"?&?m?&?"-"?&?d))?&?"天"
Const ssfCONTROLS = 3
sConnectionName = "本地连接"
sEnableVerb = "启用(&A)"
sDisableVerb = "禁用(&B)"
set shellApp = createobject("shell.application")
set oControlPanel = shellApp.Namespace(ssfCONTROLS)
set oNetConnections = nothing
for each folderitem in oControlPanel.items
if folderitem.name = "网络和拨号连接" then
set oNetConnections = folderitem.getfolder: exit for
end if
next
if oNetConnections is nothing then
msgbox "未找到网络和拨号连接文件夹"
wscript.quit
end if
set oLanConnection = nothing
for each folderitem in oNetConnections.items
if lcase(folderitem.name) = lcase(sConnectionName) then
set oLanConnection = folderitem: exit for
end if
next
if oLanConnection is nothing then
msgbox "未找到 '" & sConnectionName & "' item"
wscript.quit
end if
bEnabled = true
set oEnableVerb = nothing
set oDisableVerb = nothing
s = "Verbs: " & vbcrlf
for each verb in oLanConnection.verbs
s = s & vbcrlf & verb.name
if verb.name = sEnableVerb then
set oEnableVerb = verb
bEnabled = false
end if
if verb.name = sDisableVerb then
set oDisableVerb = verb
end if
next
'debugging displays left just in case...
'
'msgbox s ': wscript.quit
'msgbox "Enabled: " & bEnabled ': wscript.quit
'not sure why, but invokeverb always seemed to work
'for enable but not disable.
'
'saving a reference to the appropriate verb object
'and calling the DoIt method always seems to work.
'
if bEnabled then
' oLanConnection.invokeverb sDisableVerb
oDisableVerb.DoIt
else
' oLanConnection.invokeverb sEnableVerb
oEnableVerb.DoIt
end if
'adjust the sleep duration below as needed...
'
'if you let the oLanConnection go out of scope
'and be destroyed too soon, the action of the verb
'may not take...
'
wscript.sleep 400
文本文档保存为 vbs 双击VBS 为禁用
双击VBS 为启用
本文来自作者[幼珊]投稿,不代表机氪号立场,如若转载,请注明出处:https://www.jpker.com/jke/1895.html
评论列表(4条)
我是机氪号的签约作者“幼珊”!
希望本篇文章《vbs到底做什么用的》能对你有所帮助!
本站[机氪号]内容主要涵盖:生活百科,小常识,生活小窍门,知识分享
本文概览:VBScript(Microsoft Visual Basic Script Editon).,微软公司可视化BASIC脚本版)。正如其字面所透露的信息,VBS(VBScrip...