Solved

Windows Clipboard issue

Posted on 2014-12-19
19
253 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
  • 8
  • 7
  • 2
  • +1
19 Comments
 
LVL 78

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 45

Expert Comment

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

Open in new window

0
 
LVL 37

Expert Comment

by:Gerwin Jansen
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
 

Author Comment

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

Object required: WshShell.
0
 
LVL 37

Expert Comment

by:Gerwin Jansen
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 37

Expert Comment

by:Gerwin Jansen
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 37

Expert Comment

by:Gerwin Jansen
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

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

Expert Comment

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

Accepted Solution

by:
Gerwin Jansen earned 500 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 37

Expert Comment

by:Gerwin Jansen
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 37

Expert Comment

by:Gerwin Jansen
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 37

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now