Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use VBS to run executable programs in the same directory

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to use VBS to run executable programs in the same directory, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The code is as follows:

Set objShell = CreateObject ("WScript.shell")

StrCurrentDir = objShell.CurrentDirectory

Set fso = createobject ("scripting.filesystemobject")

Set f=fso.getfolder (strCurrentDir)

For Each i In f.files

If LCase (right (iPol 4)) = ".exe" Then objShell.Run iPerry true

Next

You can also get the directory where the script is located:

The copy code is as follows:

Set fso = createobject ("scripting.filesystemobject")

Fso.GetParentFolderName (WScript.ScriptFullName)

I can't think of a better way to judge whether the file is .exe or not. That's it.

The copy code is as follows:

Option Explicit

Dim oFS: Set oFS = CreateObject ("Scripting.FileSystemObject")

Dim oWS: Set oWS = CreateObject ("WScript.Shell")

WScript.Echo "Script:"

WScript.Echo "ScriptFullName:", WScript.ScriptFullName

WScript.Echo "ScriptFullPath:", oFS.GetParentFolderName (WScript.ScriptFullName)

WScript.Echo "Current:"

WScript.Echo "FS:", oFS.GetAbsolutePathName (".\")

WScript.Echo "WS:", oWS.CurrentDirectory

-output-

C:\ wis\ _ vbs\ 0506\ dev\ forum

Cscript curdir.vbs

Script:

ScriptFullName: C:\ wis\ _ vbs\ 0506\ dev\ forum\ curdir.vbs

ScriptFullPath: C:\ wis\ _ vbs\ 0506\ dev\ forum

Current:

FS: C:\ wis\ _ vbs\ 0506\ dev\ forum

WS: C:\ wis\ _ vbs\ 0506\ dev\ forum

C:\ wis\ _ vbs\ 0506\ dev\ forum

Cd..

C:\ wis\ _ vbs\ 0506\ dev

Cscript forum\ curdir.vbs

Script:

ScriptFullName: C:\ wis\ _ vbs\ 0506\ dev\ forum\ curdir.vbs

ScriptFullPath: C:\ wis\ _ vbs\ 0506\ dev\ forum

Current:

FS: C:\ wis\ _ vbs\ 0506\ dev

WS: C:\ wis\ _ vbs\ 0506\ dev

The above is all the contents of the article "how to use VBS to run executable programs in the same directory". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report