VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   vbs to send contents of clipboard to File explorer (https://forums.vandyke.com/showthread.php?t=12364)

questorfla 05-21-2016 04:44 PM

vbs to send contents of clipboard to File explorer
 
This started out as a 'what if' that came from trying to get selected text to be used as a key for regedit. I found a way to do that one but I wondered how hard it would be to use the contents of clipboard for input on other commands
Could it be sent to file explorer as a path to a file? This was a question I ran across but not sure if it would need to be tested before entering.
Such as:
If 'c:\Somedir\SomeFolder\anotherFolder\' exists then go there.

jjh 05-23-2016 04:57 PM

Hi questorfla.

You could do what you are wanting by using the following script:

Code:

' BrowseToLocationInClipboard.vbs
'

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

' Get data from clipboard into variable named: strData
strData = crt.Clipboard.Text

' Check to see if a file or folder exists with that name:
If objFSO.FileExists(strData) Then
objShell.Run "explorer /e,/select," & chr(34) & strData & chr(34)
End If

If objFSO.FolderExists(strData) Then
objShell.Run "explorer /e," & chr(34) & strData & chr(34)
End If

Does this work for you?

Thanks
JJH


All times are GMT -6. The time now is 11:45 PM.