0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

現場で活躍しそうなVBS

Posted at

現場で活躍しそうなVBS

Part1 ファイルパス、ファイルネーム編

実務なので少し役に立ちそうなのでメモ

現場では見れないブログが多いので有益なブログに記載されているコードを
引用しております。

win10 ファイル絶対パスをクリップボードへコピー

Set WshShell = Wscript.CreateObject("WScript.Shell")

Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")

strTemp = WshShell.ExpandEnvironmentStrings("%temp%")

strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )

objHandle.Write Wscript.Arguments(0)

Set WshShell = Wscript.CreateObject("WScript.Shell")

Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )

win10 ファイルネームをクリップボードへコピー
Set WshShell = Wscript.CreateObject("WScript.Shell")
Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")


strTemp = WshShell.ExpandEnvironmentStrings("%temp%")
strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )

strName = Wscript.Arguments(0)

aPath = Split(strName,"\")

strName = aPath(Ubound(aPath))

objHandle.Write strName

Set WshShell = Wscript.CreateObject("WScript.Shell")

Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )
win10 複数のファイルパスをクリップボードへコピー

Set Fso = Wscript.CreateObject("Scripting.FileSystemObject")

str = ""

For I = 0 to Wscript.Arguments.Count-1

aData = Split( Wscript.Arguments(I), "\" )

str = str & aData(Ubound(aData)) & vbCrLf

Next

strTemp = WshShell.ExpandEnvironmentStrings("%temp%")

strPath = strTemp & "\__clipCommand.tmp"

Set objHandle = Fso.OpenTextFile( strPath, 2, True )

objHandle.Write str

Call WshShell.Run( "cmd.exe /c clip < """ & strPath & """", 0, True )

引用先

logical error様

0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?