run vb script file without prompting to open/save  | Member | | Join Date: Aug 2007
Posts: 96
| | |
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
|  | Moderator | | Join Date: May 2007 Location: United Kingdom
Posts: 395
| | | re: run vb script file without prompting to open/save
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: - Go into Internet Information Services.
- Right-click on the website serving the VBS file and click Properties.
- Select the Home Directory tab, and down the bottom, click Configuration.
- Click Add
- 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
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save
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.
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save
Anu,
Can you change the file extension to .ASP ?
Jared
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save
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
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save
Anu,
How are you navigating to the page? It sounds like you are just opening it with explorer.
Jared
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save Quote:
Originally Posted by jhardman 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
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save
Anu,
From where are you redirecting? from another .ASP or .VBS page?
Jared
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save Quote:
Originally Posted by jhardman 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
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save
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
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save
Hi Jared,
Please find my answers with ur points: Quote:
Originally Posted by jhardman 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 Quote:
Originally Posted by jhardman - 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 Quote:
Originally Posted by jhardman - 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. Quote:
Originally Posted by jhardman Besides that, I can't see why there would be a problem.
Jared
Can u plz help me now?
Thanks a lot
Regards,
Anu
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save Quote:
Originally Posted by AnuSumesh ...
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
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save Quote:
Originally Posted by jhardman 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
|  | Moderator | | Join Date: Jan 2007 Location: logan, utah
Posts: 2,690
| | | re: run vb script file without prompting to open/save
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
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save Quote:
Originally Posted by jhardman 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
|  | Moderator | | Join Date: May 2007 Location: United Kingdom
Posts: 395
| | | re: run vb script file without prompting to open/save
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: - <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
|  | Member | | Join Date: Aug 2007
Posts: 96
| | | re: run vb script file without prompting to open/save
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
|  | Similar ASP / Active Server Pages bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|