473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

run vb script file without prompting to open/save

AnuSumesh
Hi,

I am ridirecting page to vbs file.
File is running properly but it is asking user to open/save the file.
But i want that it should run without any dialouge box.

My code is :

<%@language="vbscript" %>

<% dim a

a=request.form("sometextbox")
if a="" then
%>
<html>
<body>

--------some code -------
</body>
</html>

<%
else
response.redirect("file.vbs")
end if
%>

It is first asking me to open or save the file.
If i click "open" then it asks to run or don't Run

But i want it to run directly without any user input.

Can anyone help me in this issue.
Thanks in advance.

Anu
Dec 10 '07 #1
16 20797
JamieHowarth0
533 Expert 512MB
Hi Anu,

The problem you face is that you have to get your web server to process the VB code in the file, before serving the resulting HTML code back to the user (exactly the same as an ASP file), otherwise you will end up with your user viewing all of your lovely VB code in their browser and feeling horribly confused...

You get round this by doing the following:
  1. Go into Internet Information Services.
  2. Right-click on the website serving the VBS file and click Properties.
  3. Select the Home Directory tab, and down the bottom, click Configuration.
  4. Click Add
  5. In Extension, type "vbs" (without the quotes), and in Executable, type C:\Windows\system32\inetsrv\asp.dll
Your server will now process VBS files in the same manner as ASP files, and should process as normal.


Failing that, just rename your file to a file extension of ".asp"!

Best regards,

medicineworker
Dec 10 '07 #2
Hi Medicineworker,


First of all thanks for reply.

My vbs file is executing without any problem.
Main thing is i dont want "file download-security warning" dialogue which is asking me to open/save the file.
I want to execute the file without user intervention.

I tried the way u told: but in this way it does not execute the file but it is displaying the whole code of vbs file into browser. and that is really horrible.

I am giving u the code for my vbs file:
abc.vbs -this is to call remote desktop of particular IP:

On Error Resume Next

Dim ForReading

Dim Filename,fil,fold
Filename="C:\temp.txt"

ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")

set fil=objFSO.GetFile("c:\temp.txt")

If objFSO.FileExists(Filename) Then

Set objTextFile = objFSO.OpenTextFile _
(Filename, ForReading)

IP=objTextFile.ReadLine
objTextFile.close

'Delete the temporary file
fil.delete(true)

'Call RDP

dim wshell
set wshell=CreateObject("WScript.Shell")
wshell.Run "C:\windows\system32\mstsc.exe /v:"& IP
set wshell=nothing
End If

this is executing fine but needs user intervention that i dont want.

Your help is very much appreciated. Thank you.

Anu.
Dec 11 '07 #3
jhardman
3,406 Expert 2GB
Anu,

Can you change the file extension to .ASP ?

Jared
Dec 12 '07 #4
Hi Jared

Thanks for reply.
I changed the extension to asp. but then it is displaying the contents of the file as it is in the browser.

Thanks,
Anu
Dec 12 '07 #5
jhardman
3,406 Expert 2GB
Anu,

How are you navigating to the page? It sounds like you are just opening it with explorer.

Jared
Dec 13 '07 #6
Anu,

How are you navigating to the page? It sounds like you are just opening it with explorer.

Jared
Hi Jared,

I am using
response.redirect("file.vbs")
to execute vbs file. this vbs file is to run exe file for remote desktop.
As u told to change the extension to asp. I tried it as follows:
response.redirect("file.asp")
but then it was displaying the contents of the file on the browser.

Please help me in this issue.

Thanks

Anu
Dec 13 '07 #7
jhardman
3,406 Expert 2GB
Anu,

From where are you redirecting? from another .ASP or .VBS page?

Jared
Dec 13 '07 #8
Anu,

From where are you redirecting? from another .ASP or .VBS page?

Jared
Hi Jared,

I have given the code for my first asp page in my first post.
from that page i m redirecting to vbs page.
vbs file is executing properly but browser asks me to open/save the file first 'n' then if i click "open" then it asks to run/don't run. If i click "run" then vbs file executes.
I dont want these dialouge boxes( open/save and run/don't ).

Thanks,

Anu
Dec 14 '07 #9
jhardman
3,406 Expert 2GB
Anu,

What you are saying doesn't make sense, and I get the feeling I'm missing something, that's why I keep asking to reiterate basic questions. The code you have posted is the correct code, it is the correct code I use all the time, and I never have that problem. There are only a few reasons that a server would not display the script correctly:

- If the file extension is not something it recognizes, the server will prompt you to download (save or open). But if it recognizes the file extension for the first file and executes the code correctly, it shouldn't have a problem with the second (as long as the two files have the same file extension). You said the first page was an asp page, so the second one should be too.

- If the file is being opened by windows explorer instead of through an internet connection, but using a response.redirect statement should prevent that.

- If scripting is turned off for a particular file type. Somewhere deep in server settings is the option to turn on or off scripting for different types of files. Medicineworker's instructions above tell how to turn on scripting for this file type. His instructions should work perfectly. I should probably mention that scripting can also be turned off for some folders, but as long as both files are in the same folder, I don't see how this could contribute to the problem.

Besides that, I can't see why there would be a problem.

Jared
Dec 17 '07 #10
Hi Jared,

Please find my answers with ur points:
What you are saying doesn't make sense, and I get the feeling I'm missing something, that's why I keep asking to reiterate basic questions. The code you have posted is the correct code, it is the correct code I use all the time, and I never have that problem. There are only a few reasons that a server would not display the script correctly:

- If the file extension is not something it recognizes, the server will prompt you to download (save or open). But if it recognizes the file extension for the first file and executes the code correctly, it shouldn't have a problem with the second (as long as the two files have the same file extension). You said the first page was an asp page, so the second one should be too.
anu- both files have different extensions. first one is asp 'n' second one is vbs

- If the file is being opened by windows explorer instead of through an internet connection, but using a response.redirect statement should prevent that.
anu - file is opened through internet connection
- If scripting is turned off for a particular file type. Somewhere deep in server settings is the option to turn on or off scripting for different types of files. Medicineworker's instructions above tell how to turn on scripting for this file type. His instructions should work perfectly. I should probably mention that scripting can also be turned off for some folders, but as long as both files are in the same folder, I don't see how this could contribute to the problem.
anu - if i m following Medicineworker's instructions , then it just displaying the contents of vbs file in the browser.
Besides that, I can't see why there would be a problem.

Jared


Can u plz help me now?

Thanks a lot

Regards,
Anu
Dec 24 '07 #11
jhardman
3,406 Expert 2GB
...
both files have different extensions. first one is asp 'n' second one is vbs
...
Can u plz help me now?

Thanks a lot

Regards,
Anu
The file extension of BOTH files should be ".asp". ASP is a vbs file that a web server can execute. Change the file extension to .asp AND change the response.redirect line to reflect that change. Let me know if that helps.

Jared
Dec 30 '07 #12
The file extension of BOTH files should be ".asp". ASP is a vbs file that a web server can execute. Change the file extension to .asp AND change the response.redirect line to reflect that change. Let me know if that helps.

Jared
Hi Jared,

I have already tried this option.
After changing the extension to asp and also change is made in response.redirect line i.e response.redirect("runfile.asp")
it is displaying the contents of file in browser rather than executing the script.

contents of runfile.vbs file are:

On Error Resume Next

Dim ForReading

Dim Filename,fil,fold
Filename="C:\temp.txt"

ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")

set fil=objFSO.GetFile("c:\temp.txt")

If objFSO.FileExists(Filename) Then

Set objTextFile = objFSO.OpenTextFile _
(Filename, ForReading)

IP=objTextFile.ReadLine
objTextFile.close

'Delete the temporary file
fil.delete(true)

'Call RDP

dim wshell
set wshell=CreateObject("WScript.Shell")
wshell.Run "C:\windows\system32\mstsc.exe /v:"& IP
set wshell=nothing
End If

Please suggest me any other option. I got stuck here.

I have read in one of the forums that for running vbs file from asp file we have to set some MIME type. But what should be the MIME type for executing vbs file from asp file?

Can u please provide your valuable help ?

Thanks 'n' Regards,
Anu
Dec 31 '07 #13
jhardman
3,406 Expert 2GB
Clear the cache or check from a different computer. It is possible that your computer has stored the old version and isn't allowing the server to send the new version. I can't think of anything else. Maybe you could post in the IIS forum.

Jared
Dec 31 '07 #14
Clear the cache or check from a different computer. It is possible that your computer has stored the old version and isn't allowing the server to send the new version. I can't think of anything else. Maybe you could post in the IIS forum.

Jared
Hi Jared,

Thanks first of all. I have posted this on IIS now.
My only purpose is to call RDP on click of link.

'n' I have solved my problem temporarily by calling javascript function instead of vbs file as follows:
<script language="javascript">
function setip(ip)
{
var wshell;
wshell=new ActiveXObject("WScript.Shell");
wshell.Run("C:\\windows\\system32\\mstsc.exe /v:"+ip);
}
</script>
<body>
<a href="#" onclick="javascript:setip('192.20.31.1')"> RDP </a>
</body>

is it correct way of doing?
in above code mstsc,exe should be present in client side.

But I have one doubt related to msctc.exe file in case of vbs file.
In the vbs file i am running mstsc.exe file as follows:
wshell.Run "C:\windows\system32\mstsc.exe /v:"& IP

I want to ask that the file mstsc.exe used for RDP is called from client side or from server side?
If it is at client side 'n' in case it is not available at client side then how can i download it from server side?

Please provide me your valuable help.

Thanks again.

Regards,
Anu
Jan 2 '08 #15
JamieHowarth0
533 Expert 512MB
Hi Anu,

If you want to run the RDP executable when a user clicks on a link, surely instead of calling WScript to run it, simply use the following link code:
Expand|Select|Wrap|Line Numbers
  1. <a href="file://C:/WINDOWS/system32/mstsc.exe%20\/r%20YOURIPHERE">Click to launch Remote Desktop</a>
That way, you avoid the problem of getting a piece of VBS code downloaded and run on the user's machine as you parse the server's IP into the link and when the user clicks on it it gets passed to the local application instance of RDP.

medicineworker
Jan 20 '08 #16
Hi medicineworker,

Thanks for reply.
I have tried this but its not working.
But now i m using javascipt function rather than vbs function and its working fine.
But the problem is the file mstsc.exe should be present on client machine.
Can you please tell me that is this file available in Windows-95/98/2000 machines also?
If yes then my problem is solved. But if no then i have to first download the file on client machine before running the file.

Thanks,
Anu
Jan 21 '08 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kim | last post by:
GOOD morning, I try to open xx.vbs in <href="./xx.vbs"></hef> but it pop up the file download mesage. How can i disabled it? I try another solution like this : set ws =...
7
by: mattmerc | last post by:
Hi all, We have all seen lot of method for exporting datagrids to Excel. I have a slightly different need. I think it should be easy to accomplish but I am not sure how. I would like when a user...
2
by: Torres | last post by:
Dear all, I use this "HyperLink1.NavigateUrl = "\\aoui\myeoe\testing.bat" to run the batch file. The windows will show a messagebox "RUN" "SAVE" OR "CANCEL". I want to run the batch file...
1
by: billelev | last post by:
I have written some code that allows the printing of a report to a pdf file. Ideally, I would like to name the file via code and not have the pdf application prompt the user for a file name. I have...
1
by: Iain | last post by:
Hi All I have a datagrid - buit dynamically from a database table - which contains a column with links to many documents. When the user selects a link I want them to be able to open the document...
1
AnuSumesh
by: AnuSumesh | last post by:
Hi, I am redirecting from asp page to vbs file.The VBS script resides on same folder as of asp pages in my windows/IIS server. I am using windows2003 and IIS 6.0. Script is running properly but...
3
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
I have a asp.net page, it uses js to print in IE. It always has the prompting user window appear. I have tried: <input onclick="document.all.WebBrowser.ExecWB(6,6)" type="button"...
1
by: mihir0288 | last post by:
I m writing a code in c# where i m using a web browser control now i want to save the HTML file that i have opened in the web browser control on my hard disk without prompting save file dialog box....
0
by: raulbolanos | last post by:
I guys, I got 2 days trying to go thought this and I cannot figure out how to solve it, hope you can help me out here. I have a ASP Web Application, as simple as this; <%@ Page Language="C#"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.