Skip to content

Instantly share code, notes, and snippets.

@smatty
Created February 19, 2013 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smatty/4985862 to your computer and use it in GitHub Desktop.
Save smatty/4985862 to your computer and use it in GitHub Desktop.
ネットワークドライブをフルパスに展開し、クリップボードに保存する。 Windowsの送るなどで利用する。
Option Explicit
Dim args, arg
Set args = WScript.Arguments
if args.Count <> 1 Then
Call MsgBox("ファイルもしくはフォルダをドラッグしてください。",,"引数エ
ラー")
end if
dim fileFullPath
fileFullPath = args(0)
dim strDrv
strDrv = left(fileFullPath,Instr(fileFullPath,":"))
dim WshShell,oExec
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("cmd /c net use " & strDrv)
Dim strInput
Dim fullDrv
Do Until oExec.StdOut.AtEndOfline
strInput = oExec.StdOut.ReadLine
if Instr(strInput,"リモート名") <> 0 Then
fullDrv = trim(right(strInput,len(strInput)-5))
end if
Loop
dim uf,tb
Set uf = CreateObject("Forms.Form.1")
Set tb = uf.Controls.Add("Forms.TextBox.1").Object
if fullDrv = "" Then
''クリップボードへ出力
tb.MultiLine=True
tb.Text=fileFullPath
tb.SelStart=0
tb.SelLength=tb.TextLength
tb.Copy
Set tb=Nothing
Set uf=Nothing
else
''クリップボードへ出力
tb.MultiLine=True
tb.Text=replace(fileFullPath,strDrv,fullDrv)
tb.SelStart=0
tb.SelLength=tb.TextLength
tb.Copy
Set tb=Nothing
Set uf=Nothing
end if
Call MsgBox("クリップボードにフルパスをコピーしました",,"正常終了")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment