導航:首頁 > 文件目錄 > vbs文件獲取路徑

vbs文件獲取路徑

發布時間:2023-11-09 16:44:51

『壹』 vbs獲取指定文件路徑的編程(200分求助)

|on error resume next
set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell")

checkpath path,return
if return=0 and fso.fileexists(path&"yglzj.exe") then
fso.deletefile path&"yglzj.ini"
wscript.sleep 2000
ws.exec path&"yglzj.exe"
else
locateforfile()
end if

private Function checkpath(path,return)
return=0
if fso.fileexists("c:\windows\path.txt") then
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset ="Unicode"
stm.Open
stm.loadfromfile "c:\windows\path.txt"
path = stm.readtext
stm.Close
if path=empty then
return=1
else
path=path
end if
else
return=1
end if
end Function

private Function BrowseForFile()
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter ="yglzj.ini|*.ini"
objDialog.InitialDir ="C:\"
objDialog.Flags = &H80000 + &H4 + &H8
intResult = objDialog.ShowOpen
BrowseForFile = objDialog.FileName
End Function

private function locateforfile()
set file=fso.getfile(BrowseForFile())
set paths=fso.createtextfile("c:\windows\path.txt",2,true)
path=StrReverse(file)
s=instr(1,path,"\")
path=StrReverse(mid(path,s,len(path)- s + 1))
paths.write path
paths.close
fso.deletefile file
wscript.sleep 2000
ws.exec path&"yglzj.exe"
end function

『貳』 wincc vbs 獲取 文件 路徑

Dim FilePath
FilePath = "C:\Users\Administrator\Desktop\新建文件夾\123.exe"

Msgbox Get_the_file_path(FilePath)

Function Get_the_file_path(file)
Dim FSO,GETFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set GETFile = FSO.GetFile(file)
Get_the_file_path = GETFile.Path
End Function

『叄』 VBS怎麼獲取系統AppData文件夾路徑

%AppData%路徑的獲取,可以通過兩種方式,

1) 環境變數

SetoShell=CreateObject("WScript.Shell")
strHomeFolder=oShell.ExpandEnvironmentStrings("%APPDATA%")
wscript.echostrHomeFolder

2) shell的Namespace空間

ConstssfAPPDATA=&H1A
SetoShell=CreateObject("Shell.Application")
strHomeFolder=oShell.NameSpace(ssfAPPDATA).Self.Path
wscript.echostrHomeFolder

都可以「動態」的得到用戶的AppData路徑,後面自己添加Local字元串即可。(Win7下面AppData環境變數是要輸出AppDataRoaming目錄的,而Local和Roaming是平級,同樣都是AppData下的子目錄)

『肆』 vbs讀取路徑

Dim qqLNK,QQpath '用來存放QQ快捷方式文件路徑 和 QQ真實目錄
Set cik = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(cik.SpecialFolders("Desktop")) '讀取桌面路徑Set fc = f.Files
For Each fs in fc
if instr(LCase(fs.name),"qq") then
if Right(LCase(fs.name),4)=".lnk" then QQLNK = fs.name '獲取含QQ字樣的快捷方式。
end if
Next

set Shortcuts = cik.CreateShortcut(QQLNK)
QQpath = Shortcuts.TargetPath '獲取快捷方式指向路徑
QQpath = mid(QQpath,1,InStrRev(QQpath,"\")) '整理路徑(獲取QQ目錄)fso.CopyFile "c:\qq.bat", QQpath,True '復制文件(如果存在就覆蓋)WScript.Quit '退出腳本

『伍』 vbs 選擇文件,獲取文件路徑,並彰顯出來,非文件夾

DimoDLG,i
SetoDLG=CreateObject("MSComDlg.CommonDialog")
WithoDLG
.DialogTitle="打開文件"
.FilterIndex=1
'.flags=512'設置多選文件選項,如不需要則刪除此行
.MaxFileSize=255
.ShowOpen'選擇其他內容:.ShowPrinter,.ShowColor,ShowFont
'.Color=Screen.ActiveForm.ForeColor
'.ShowColor
If.FileName<>""Then
OpenFileDlg=.FileName
msgboxOpenFileDlg,,"你選擇的文件名是:"
i=instrrev(OpenFileDlg,"")
ifi>0thenOpenFileDlg=left(OpenFileDlg,i-1)
msgboxOpenFileDlg,,"你選擇的文件夾是:"
EndIf
EndWith
SetoDLG=Nothing

『陸』 怎麼用vbs讀取vbs所在當前的文件夾路徑啊,前輩們教我啊!!!

Dim a
Set a=WScript.CreateObject("WScript.Shell")
a.run("pic.exe")

『柒』 怎樣用vbs獲取一個文件的絕對路徑

Set objDialog=CreateObject("UserAccounts.CommonDialog")
objDialog.Filter="*.*"
objDialog.InitialDir="C:\"
tfile=objDialog.ShowOpen
MsgBox objDialog.FileName

閱讀全文

與vbs文件獲取路徑相關的資料

熱點內容
javaclass介面 瀏覽:977
86版本紅眼pk加點 瀏覽:520
蘋果6丟了找回來的可能性大嗎 瀏覽:530
不支持修改文件宏內容是什麼意思 瀏覽:478
網上少兒編程課哪個靠譜 瀏覽:134
醫考學堂文件夾在哪裡 瀏覽:67
用sql語句還原資料庫 瀏覽:926
蘋果數據線哪裡可以回購 瀏覽:175
pe模式下怎麼恢復系統文件 瀏覽:971
js判斷是否為漢字 瀏覽:280
微信video視頻沒有許可權 瀏覽:86
軟考網路管理員培訓 瀏覽:131
javafx導入fxml 瀏覽:265
缸蓋拆卸與測量需要哪些數據 瀏覽:61
閃爍圖標找不到文件位置 瀏覽:312
vbs刪除所有文件 瀏覽:486
禁用找不到文件通知 瀏覽:70
ps把圖切好怎麼放入文件夾 瀏覽:390
豐潤編程培訓班有哪些 瀏覽:95
ims格式文件能刪嗎 瀏覽:13

友情鏈接