Merge pull request #2561 from ab9rf/set-df-path

set-df-path: accept path on command line
develop
Myk 2023-01-06 22:46:22 -08:00 committed by GitHub
commit 8c422103a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 8 deletions

@ -2,11 +2,21 @@ Option Explicit
Const BIF_returnonlyfsdirs = &H0001
Dim wsh, objDlg, objF, fso, spoFile
Set objDlg = WScript.CreateObject("Shell.Application")
Set objF = objDlg.BrowseForFolder (&H0,"Select your DF folder", BIF_returnonlyfsdirs)
Dim wsh, objDlg, objF, fso, spoFile, args
Set fso = CreateObject("Scripting.FileSystemObject")
set args = Wscript.Arguments
if args.count > 0 Then
Set ObjF = fso.GetFolder(args.Item(0))
else
Set objDlg = WScript.CreateObject("Shell.Application")
Set objF = objDlg.BrowseForFolder (&H0,"Select your DF folder", BIF_returnonlyfsdirs)
if IsValue(objF) Then
set ObjF = objF.self
end if
end if
If fso.FileExists("DF_PATH.txt") Then
fso.DeleteFile "DF_PATH.txt", True
End If
@ -14,7 +24,7 @@ End If
If IsValue(objF) Then
If InStr(1, TypeName(objF), "Folder") > 0 Then
Set spoFile = fso.CreateTextFile("DF_PATH.txt", True)
spoFile.WriteLine(objF.Self.Path)
spoFile.WriteLine(objF.Path)
End If
End If

@ -2,11 +2,21 @@ Option Explicit
Const BIF_returnonlyfsdirs = &H0001
Dim wsh, objDlg, objF, fso, spoFile
Set objDlg = WScript.CreateObject("Shell.Application")
Set objF = objDlg.BrowseForFolder (&H0,"Select your DF folder", BIF_returnonlyfsdirs)
Dim wsh, objDlg, objF, fso, spoFile, args
Set fso = CreateObject("Scripting.FileSystemObject")
set args = Wscript.Arguments
if args.count > 0 Then
Set ObjF = fso.GetFolder(args.Item(0))
else
Set objDlg = WScript.CreateObject("Shell.Application")
Set objF = objDlg.BrowseForFolder (&H0,"Select your DF folder", BIF_returnonlyfsdirs)
if IsValue(objF) Then
set ObjF = objF.self
end if
end if
If fso.FileExists("DF_PATH.txt") Then
fso.DeleteFile "DF_PATH.txt", True
End If
@ -14,7 +24,7 @@ End If
If IsValue(objF) Then
If InStr(1, TypeName(objF), "Folder") > 0 Then
Set spoFile = fso.CreateTextFile("DF_PATH.txt", True)
spoFile.WriteLine(objF.Self.Path)
spoFile.WriteLine(objF.Path)
End If
End If