Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > .vbs to ASP page

Reply
Thread Tools

.vbs to ASP page

 
 
tianung
Guest
Posts: n/a
 
      07-19-2009
How do I convert a .vbs script into an ASP page on the web ?

For illustration, let's say the .vbs file is "test.vbs" which contains
only one line of code:

MsgBox "Hello World !"


Do I simply create the text:

<%
MsgBox "Hello World !"
%>

and save the file as "test.asp" ? Should there be any other lines of
code apart from this ?

I've just subscribe to an "ASP host" called "x10hosting.com" - can I
simply place this "test.asp" file in the default folder (via FTP) and
link to it via Internet Explorer (version 6 still for me) ?

I tried doing this but all I got to see on Internet Explorer was the
actual script text (the script was not executed). Someone told me I
need to "enable mono" but I've no idea what this means - would
everybody trying to execute this "test.asp" have to "enable mono" on
their PC's as well ?

Just a beginner as you can see. Please help !
 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      07-19-2009
tianung wrote:
> How do I convert a .vbs script into an ASP page on the web ?
>
> For illustration, let's say the .vbs file is "test.vbs" which contains
> only one line of code:
>
> MsgBox "Hello World !"
>
>
> Do I simply create the text:
>
> <%
> MsgBox "Hello World !"
> %>


No. MsgBox will display the message on the server (ASP code is executed on
the server), so never use things like MsgBox ir Inputbox in server-side
code.

You need to think of it this way: ASP generates html to be sent to the
client using the Response object. The html is rendered by the browser and
the result is displayed to the user.

The ASP-equivalent hello-world script would be this:

<%
Response.Write "Hello World !"
%>

There are 5 main objects intrinsically available to ASP script: Request,
Response, Session, Application and Server. You can read more about them
here:
http://msdn.microsoft.com/en-us/library/ms524664.aspx

>
> and save the file as "test.asp" ? Should there be any other lines of
> code apart from this ?


No other lines of code are required. As long as the server is set up to
correctly process .asp files, that should be all you need.

>
> I've just subscribe to an "ASP host" called "x10hosting.com" - can I
> simply place this "test.asp" file in the default folder (via FTP) and
> link to it via Internet Explorer (version 6 still for me) ?


If you mean "the default folder that the host has assigned to you", then
yes, as long as the folder resides within the wwwroot folder (or is mapped
to a virtual IIS drectory) and the host has correctly configured IIS and the
directory to process .asp files using the asp.dll (this is assuming the host
is using IIS - it is possible to run ASP with an apache web server, but it
requires additional software such as Chilisoft).

>
> I tried doing this but all I got to see on Internet Explorer was the
> actual script text (the script was not executed). Someone told me I
> need to "enable mono"


I've never heard of that. I suspect you need to get some support from your
host, because there are configurations (extension-mapping, enabling ASP,
etc.) that only the host can make unless he has provided tools to enable you
to do it.


--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
 
Family Tree Mike
Guest
Posts: n/a
 
      07-19-2009
tianung wrote:
>
> I tried doing this but all I got to see on Internet Explorer was the
> actual script text (the script was not executed). Someone told me I
> need to "enable mono" but I've no idea what this means - would
> everybody trying to execute this "test.asp" have to "enable mono" on
> their PC's as well ?
>


Mono is the publicly available version of the Microsoft.Net framework.
It is commonly used to run .Net programs on non-windows machines. This
would not appear to apply in your situation.

--
Mike
 
Reply With Quote
 
tianung
Guest
Posts: n/a
 
      07-19-2009
On Jul 19, 11:04*pm, "Bob Barrows" <(E-Mail Removed)> wrote:
>
> No. MsgBox will display the message on the server (ASP code is executed on
> the server), so never use things like MsgBox ir Inputbox in server-side
> code.
>


Thanks very much Bob. You've pointed out a fundamental concept. Just
so I don't bark up the wrong tree - would the following VB script that
opens an Excel spreadsheet on the user's PC be easily translatable to
an ASP page on the web ? Or would it similarly attempt to open on the
server side ?

Dim xlApp
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
On Error Resume Next
Set oWorkbook = xlApp.Workbooks.Open("http://xxxxx.com/
MySpreadsheet.xls")
If Err.Number <> 0 Then WScript.Quit
xlApp.Visible = True
oWorkbook.Activate
xlApp.WindowState = 3
Set xlApp = Nothing

As you can see, the above VB script opens the Excel spreadsheet
(stored on the web) inside Excel itself (rather than in Internet
Explorer) on the user's PC. Is it possible to have an ASP page that
does the same ? Thanks.
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      07-19-2009
tianung wrote:
> On Jul 19, 11:04 pm, "Bob Barrows" <(E-Mail Removed)> wrote:
>>
>> No. MsgBox will display the message on the server (ASP code is
>> executed on the server), so never use things like MsgBox ir Inputbox
>> in server-side code.
>>

>
> Thanks very much Bob. You've pointed out a fundamental concept. Just
> so I don't bark up the wrong tree - would the following VB script that
> opens an Excel spreadsheet on the user's PC be easily translatable to
> an ASP page on the web ? Or would it similarly attempt to open on the
> server side ?
>


Yes. See:
http://support.microsoft.com/default...b;en-us;257757
which warns about the dangers of server-side automation of Office
applications and provides links to alternatives.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      07-19-2009
tianung wrote:
> How do I convert a .vbs script into an ASP page on the web ?
>


Building on Mike's reply, these are relevant for you as well:
http://www.boutell.com/newfaq/definitions/asp.html
http://www.packtpub.com/article/Classic-ASP (some of the information in this
is incorrect, or is no longer valid - however, the main points still hold
water)
http://www.takempis.com/aspnet_fundamentals.asp

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      07-19-2009
Bob Barrows wrote:
> tianung wrote:
>> On Jul 19, 11:04 pm, "Bob Barrows" <(E-Mail Removed)> wrote:
>>> No. MsgBox will display the message on the server (ASP code is
>>> executed on the server), so never use things like MsgBox ir Inputbox
>>> in server-side code.
>>>

>> Thanks very much Bob. You've pointed out a fundamental concept. Just
>> so I don't bark up the wrong tree - would the following VB script that
>> opens an Excel spreadsheet on the user's PC be easily translatable to
>> an ASP page on the web ? Or would it similarly attempt to open on the
>> server side ?
>>

>
> Yes. See:
> http://support.microsoft.com/default...b;en-us;257757
> which warns about the dangers of server-side automation of Office
> applications and provides links to alternatives.
>


Though I completely agree with this when generating an Excel or other
office file, I think the question was regarding a pre-generated Excel
file. This could be answered with Response.ContentType and
Response.WriteFile. Now that I think about it, I'm not sure if
Resonse.WriteFile takes a url or only a local file though.

--
Mike
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      07-19-2009
Family Tree Mike wrote:
> Bob Barrows wrote:
>> tianung wrote:
>>> On Jul 19, 11:04 pm, "Bob Barrows" <(E-Mail Removed)> wrote:
>>>> No. MsgBox will display the message on the server (ASP code is
>>>> executed on the server), so never use things like MsgBox ir
>>>> Inputbox in server-side code.
>>>>
>>> Thanks very much Bob. You've pointed out a fundamental concept. Just so
>>> I don't bark up the wrong tree - would the following VB
>>> script that opens an Excel spreadsheet on the user's PC be easily
>>> translatable to an ASP page on the web ? Or would it similarly
>>> attempt to open on the server side ?
>>>

>>
>> Yes. See:
>> http://support.microsoft.com/default...b;en-us;257757
>> which warns about the dangers of server-side automation of Office
>> applications and provides links to alternatives.
>>

>
> Though I completely agree with this when generating an Excel or other
> office file, I think the question was regarding a pre-generated Excel
> file. This could be answered with Response.ContentType and
> Response.WriteFile.


....which is the method illustrated in one of the links from this article.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
tianung
Guest
Posts: n/a
 
      07-19-2009
On Jul 20, 3:27*am, Family Tree Mike <(E-Mail Removed)>
wrote:
>
> Though I completely agree with this when generating an Excel or other
> office file, I think the question was regarding a pre-generated Excel
> file. *This could be answered with Response.ContentType and
> Response.WriteFile. *Now that I think about it, I'm not sure if
> Resonse.WriteFile takes a url or only a local file though.
>


As I know the above vbscript in its native form works nicely, is it
possible to use a ASP Classic script to do the following?

1. Either (A) copy the .vbs file from the web to the client's C:\
drive; or (B) create in the client's C:\ drive a text file with the
above vbscript code and then rename the text file (using ASP Classic)
so it has a .vbs extension;

2. Execute the newly created .vbs script in the client's C:\ drive
(using ASP Classic); and

3. Delete the .vbs script from the client's C:\ drive.

If this is possible at all, would it throw up a million alarm bells at
the user who activates the .asp script ?



 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      07-20-2009
tianung wrote:
> On Jul 20, 3:27 am, Family Tree Mike <(E-Mail Removed)>
> wrote:
>>
>> Though I completely agree with this when generating an Excel or other
>> office file, I think the question was regarding a pre-generated Excel
>> file. This could be answered with Response.ContentType and
>> Response.WriteFile. Now that I think about it, I'm not sure if
>> Resonse.WriteFile takes a url or only a local file though.
>>

>
> As I know the above vbscript in its native form works nicely, is it
> possible to use a ASP Classic script to do the following?
>
> 1. Either (A) copy the .vbs file from the web to the client's C:\
> drive; or


No - too many hackers have taken advantage of that security hole to allow it
to be kept open ....

> (B) create in the client's C:\ drive a text file with the
> above vbscript code and then rename the text file (using ASP Classic)
> so it has a .vbs extension;


Even worse ... !

>
> 2. Execute the newly created .vbs script in the client's C:\ drive
> (using ASP Classic); and


No. ASP runs on the server (this applies to both ASP and ASP.Net) ..
>
> 3. Delete the .vbs script from the client's C:\ drive.


Egads!

>
> If this is possible at all, would it throw up a million alarm bells at
> the user who activates the .asp script ?


I would hope so!

I'm not sure why you are ignoring the alternative offered in the MS KB
article I pointed you at.

--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp submitted to process asp;but calling asp page says:"Page not found" aftr 1hr Divya ASP General 2 05-11-2004 09:07 AM
using cookie in asp page in asp.net page =?Utf-8?B?bWFoc2E=?= ASP .Net 1 02-24-2004 05:04 PM
Add control to asp:PlaceHolder on asp.net page from user control on same page Dan ASP .Net 1 01-04-2004 08:14 PM
how ASP.NET page gets user input from another ASP.NET page?? Matthew Louden ASP .Net 4 11-24-2003 06:59 AM
Calling a html page from an asp page then returning to the next statement on the original asp page Chuck ASP General 0 07-05-2003 02:00 AM



Advertisments