[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Windows Clipboard issue

Posted on 2014-12-19
19
Medium Priority
?
317 Views
Last Modified: 2014-12-22
Hello,

From VBScript, I use Internet Explorer to copy a network path to my Windows clipboard.  Due to a recent Windows security update, it does not work now.  Rather than figure out what security update caused it, I just want to stop using IE for this function.  Is there a shell command or something like that I can use?  Here's my code.
Sub CommandButtonClipBoard_Click()

    On Error Resume Next

Dim strCopy
Dim objIE

JobYear = cstr(Year(Item.UserProperties("JobInitiatedDate")))

strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
objIE.document.parentwindow.clipboardData.SetData "text", strCopy
objIE.Quit

End Sub

Open in new window


Thanks,
Joel
0
Comment
Question by:Genius123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
  • 2
  • +1
19 Comments
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 40510432
Have you tried this?
a. Open Internet Explorer.
b. Click on Tools.
c. Click on Internet Options.
d. Under Security tab, Click on Internet and then click on Custom level.
e. Scroll down and under Scripting, you will find an option “Allow Programmatic clipboard access”.
f. Under that click on Enable and click OK and again OK.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40510729
You should try the htmfile object
Set oHTML = CreateObject("htmlfile")

Open in new window

0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40510766
Using clip maybe an option as well, I don't get any security warnings with that. Can you try:

...
strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine strCopy
oIn.Close
...

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Genius123
ID: 40513250
Thanks Gerwin.  I get an error.  Could you help further?

Object required: WshShell.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513524
Oops, missed a line copying from my example. Can you try again? The missin CreateObject is added below.

...
strCopy = "\\TGPS13VM1\drawing$\Jobs-"+JobYear+"\"+Item.UserProperties("JobNumber")+" "+Item.UserProperties("JobName")

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine strCopy
oIn.Close
...

Open in new window

0
 

Author Comment

by:Genius123
ID: 40513545
Thanks for your help on this.  Now I get this error on this line:

Set oExec = WshShell.Exec("clip")

The system cannot find the specified file.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513561
Hmm, this is a Windows7 machine you are working on, right? I am and clip.exe is in the path. But if it is not, you can do this:

Set oExec = WshShell.Exec("%SYSTEMROOT%\system32\clip.exe")
0
 

Author Comment

by:Genius123
ID: 40513572
Yes, I'm on Win 7 64 bit.  I tried that line and it gives me the same error.  Any other ideas?
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513656
Strange, I have WIn7 64 bit as well, can you try and find "clip.exe" on a cmd prompt"

cd %SYSTEMROOT%
dir /a /s clip.exe

and post your results?
0
 

Author Comment

by:Genius123
ID: 40513681
Here's what I get.  See attached.
Document1.pdf
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40513697
you might need to run the clip.exe from the syswow64 directory.
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 2000 total points
ID: 40513701
Looks OK to me (I have the exact same). Maybe some weird path setting.

Can you try and see if clip itself is working:

C:\Windows\system32>echo HELLO | clip

Then paste in some other application, you should paste 'HELLO'.

Then, if that works, try:
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe") 

Open in new window


Also, try my test script:
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe")
Set oIn = oExec.stdIn
oIn.WriteLine "HELLO Genius123"
oIn.Close

Open in new window


Save as somefile.vbs and run it, after which you should be able to past 'Hello Genius123' somewhere.

Tip: you may want to remove some personal info from your pdf writer or Word :)
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513721
>> you might need to run the clip.exe from the syswow64 directory.
It is running just fine from %SYSTEMROOT%\system32 for me ;)
0
 

Author Comment

by:Genius123
ID: 40513856
I tried both and here's what I get.  See attached.
Document2.pdf
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513888
Instead of posting PDF's you can also just paste the text from your CMD prompt ;)

You must not copy the complete text I pasted above, that will not work.

- open a cmd prompt
- type: cd \windows\system32
- type: echo HELLO | clip
- open notepad and paste (ctrl-v) there.

Does that work?
0
 

Author Comment

by:Genius123
ID: 40513917
Yes!  That worked.  It also works from the script.  Thanks very much for your help :-)

Just so it's documented, this is the final answer:

Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\Windows\system32\clip.exe")
Set oIn = oExec.stdIn
oIn.WriteLine "HELLO Genius123"
oIn.Close
0
 

Author Closing Comment

by:Genius123
ID: 40513920
Yes!  That worked.  It also works from the script.  Thanks very much for your help :-)
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40513925
Great, glad we could help you out ;)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question