Created
February 19, 2013 13:26
-
-
Save smatty/4985862 to your computer and use it in GitHub Desktop.
ネットワークドライブをフルパスに展開し、クリップボードに保存する。
Windowsの送るなどで利用する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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