Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-21-2016, 03:44 PM
questorfla questorfla is offline
Registered User
 
Join Date: May 2016
Posts: 1
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.
Reply With Quote
  #2  
Old 05-23-2016, 03:57 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 815
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
Reply With Quote
Reply

Tags
vbscript

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:20 PM.