Send a parameter from a website to a application (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


JeroenDortmans -> Send a parameter from a website to a application (1/10/2002 8:18:23)

I have a website with a database running on a server. Some numbers stored in this database can be used to view drawings outside this website with the help of a special windows based application. When I make a BAT file which holds the path to this special windows based application and a number of a drawing, the application is opened with the right drawing. The BAT file would look like this:
echo off
<path> 1234567
exit
Now I want to open this application with the right drawing directly from the website. When I to do this with a hyperlink using a parameter from the database the application is opened, but the parameter isn't "entered", so you don't see the drawing. Is there a special way to send parameters from a website to a windows based application? I really need help with this one!!!


 




rdouglass -> RE: Send a parameter from a website to a application (1/10/2002 12:24:42)

If you know the location of the file, you may not have to use the batch file (and the file has to be associated with an app). I've done it by using 'file://path/filename'. Something like:

file://F:\shared\docs\mydoc.doc

instead of the http://.... I don't know all your particulars (maybe you need to load special stuff thru the bat), but this does work in a controlled environment (Intranet) quite nicely. The only prob is that when opening, you'll get the Open / Save option (unless you click on the "always..." option).

Hope it helps...

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/11/2002 3:05:07)

I know how to start the application with a link. My problem is starting the application with the parameter "inserted". When I do this with a BAT file it works, now I want to do this with a hyperlink carrying the parameter just like the BAT file. I did try sending a parameter with a hyperlink from a website with a database, but this did start the application but didn't "insert" the parameter.

 




rdouglass -> RE: Send a parameter from a website to a application (1/11/2002 13:37:20)

So let me get this right...you want to dynamicaly build a .BAT file (from DB , form data, whatever) and pass it to the browser to execute?

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/12/2002 13:06:51)

No, I want to open an application and also send a parameter to this application from a webserver so it will open the right file. The application is designed to be executed with the right parameter by a BAT file. So it will show the right file requested with the parameter send by this BAT file. Opening the application with the right parameter by using a BAT file works fine. Now I have problems to open this application with the right parameter from a DB driven website. I can open the application, but can’t send the parameter like I can with the BAT file. Can you help me with this?

 




rdouglass -> RE: Send a parameter from a website to a application (1/12/2002 21:48:02)

Anyone out there with ideas, ring in...

There is almost always a way. Where does the file reside? If I'm reading this correctly, the batch file (that was sucessful) was run at the client and not the server. If that's the case, then the files themselves do not necessarily reside on the host. Can I assume an Intranet with file server / local HD file storage??

Could you not generate a text file using FileSystemObjects (if your host is NT), then rename to a .BAT and send that to the client?? At least conceptually at this point, would that solve the problem??

IOW, can you manually build a .BAT file, put it on the host, point a browser to it, and sucessfully open the app at the client? If that is the case, we should be able to dynamically build the .BAT from your DB...

Am I on the right track??

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/14/2002 7:23:51)

Hi rdouglass,

You are on the track and I want to say that I appreciate your help very much.
About your question's. The batch file (that was successful) was indeed running at the client and not the server. It is indeed an Intranet environment with the application running from a network HD. The application is an MS Access DB with VB user interface.
I also was thinking of creating a .txt file and rename it to .BAT and include the link with the right parameter. This should work.
I am not that good with VBS or JavaScript to develop such a script my self in a short time. Can you give me an idea how the script should look like?
I think with VB you can execute a file and send a parameter like a .BAT file does. Isn't this also possible with VBS?


 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/15/2002 17:37:02)

Could somebody please help me with this “problem”!

 




rdouglass -> RE: Send a parameter from a website to a application (1/17/2002 9:14:05)

Sorry it took so long to get back. I think I can help. We CAN build a batch file and pass that to the client (If that is acceptable). What we would need to do is to build the file dynamically using FileSystemObject (FSO). Here is a good start for building a text file - you would just name your file as a .bat file instead of a .txt file as in the example here:

http://www.4guysfromrolla.com/webtech/040699-1.shtml

I would suggest getting the FSO to first build a .bat file that works using static values. Then, once that works, replace your static values with your db values.

Make sense at all???

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/17/2002 10:14:23)

I have figured out the script to create the BAT file. In this phase of solving this problem I create the BAT file on C:.
When I edit the properties of the BAT file which will shut the BAT file after "running", Windows will create a shortcut file to the BAT file. When I "run" this shortcut the BAT file is opened, the application is started with the right parameter and after that the BAT file is closed.
„H Now I must have VBS code to "run" the BAT file after it is created by the code I now have. This code must have a link to the shortcut as I described.
„H After that I place the script on the webserver and try to dynamically insert the parameter in the BAT file.

Here is the code I now have.

<SCRIPT LANGUAGE="VBScript">
<!--
dim filesys, filetxt, getname, patht, ts, s
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\View_VOG.BAT", True)
path = filesys.GetAbsolutePathName("c:\View_VOG.BAT")
getname = filesys.GetFileName(path)
filetxt.WriteLine ("echo off")
filetxt.WriteLine ("\\IS0001\Shared_Apps\DAF_Progs\Trace2\TraceDirectView 51230/01-219")
filetxt.WriteLine ("exit")
filetxt.Close
-->
</SCRIPT>

 




rdouglass -> RE: Send a parameter from a website to a application (1/17/2002 12:49:03)

Just a little more help possibly. This is the test code I used on my server (WinNT / IIS4).... All this between the <body></body> tags:

<% DIM myDocPath

myDocPath = "\\SERVER\HOMEDIR\CCW.JPG"
'just a sample file to reference
'you would replace this with your DB record result

'now your code

dim filesys, filetxt, getname, patht, ts, s
Set filesys = CreateObject("Scripting.FileSystemObject")

Set filetxt = filesys.CreateTextFile("G:\inetpub\wwwroot\bats\View_VOG.BAT", True)
'my absolute path on the server for a folder
'in my root web. Need to give this folder
'read/write access hence a seperate folder

path = filesys.GetAbsolutePathName("G:\inetpub\wwwroot\bats\View_VOG.BAT")
getname = filesys.GetFileName(path)
filetxt.WriteLine ("echo off")

filetxt.WriteLine (myDocPath)
'use your var grabbed in the second line

filetxt.WriteLine ("exit")
filetxt.Close
%>

(a line to test our bat)
<p><a href="bats\View_VOG.BAT">Click</a></p>


Try this part out to see if we made it this far. If this works, then we can probably just send the file to the browser. The only downfall is clicking on that Run-Save-Cancel dialogue that the browser throws up...

Hope this helps....

EDIT: Threw some blank lines in to make it more readable...

Edited by - rdouglass on 01/17/2002 12:55:08




JeroenDortmans -> RE: Send a parameter from a website to a application (1/18/2002 8:42:45)

Hi rdouglass,

I did spend some time on the script but still have some questions.
The person who manages the webserver is out, so I am still referring to c:\View_VOG.BAT as location to place the BAT file. Later I will edit the script so it will place the BAT on a webserver location that is read/write enabled.

I can't get the parameter from the database into the script. The script is placed on a page which is a search result page. There is only 1 "Drawing_number" on this search result page.

I want to "run" the BAT file directly after the "make BAT file script". How to do this?

I inserted a button to activate the script. What I want is to click on the Drawing number displayed and activate the script. So make a hyperlink from this Drawing number and activate the script when selecting the hyperlink.

When this works I want to make the variable "Path_BAT" depend on which domain the user is connected to.

This is the code that I have now.

<script language="VBScript">
<!--
Sub ViewVog_onClick

DIM Path_BAT, DrawingNrVar, ComplPath
Path_BAT = "\\IS0001\Shared_Apps\DAF_Progs\Trace2\TraceDirectView"
DrawingNrVar = "SELECT * FROM Connectoren WHERE (Drawing_number = '::Drawing_number::')"
ComplPath = Path_BAT + " " + DrawingNrVar

DIM filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("c:\View_VOG.BAT", True)
path = filesys.GetAbsolutePathName("c:\View_VOG.BAT")
getname = filesys.GetFileName(path)
filetxt.WriteLine ("echo off")
filetxt.WriteLine (ComplPath)
filetxt.WriteLine ("exit")
filetxt.Close

End Sub
-->
</SCRIPT>

<input type="button" name="ViewVog" value="View Vog">


 




rdouglass -> RE: Send a parameter from a website to a application (1/18/2002 15:30:04)

Am I missing something or are you trying to run this code at the client?? IIRC encapsulating the code inbetween <script> tags will tell it to run at the client. I believe we want this to run at the server, (Don't We????) Maybe I'm not clear on the end goal and the parameters.

My assumptions:

1. DB on server
2. Process scripts on server
3. Pass parameters to client app and open file

If this is the case, I don't think your code will work in its current config. To process at the server, you need to encapsulate it in '<%' and '%>' like my examples. If we build it like that (server based), you won't be able to use "C:\whatever" as your path to store your .bat (temporarily). I guess we could make it process at the client, I just don't know of any good reason why you should. If you want to process this script at the client, you'll need to ensure every user has the Windows Scripting Host (WSH) installed.

In addition, I would be sure I can build a file before I send it. We can send it easy enough, we just want to be sure it's built properly....

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/18/2002 16:58:32)

You are completely right. I am not that familiar with VBS, but I am learning hard now. So the script has to run on the server, that’s right. You are very clear, but I didn’t understand the difference between <% %> and <script language="VBScript"> </SCRIPT>. Now I do. Sorry for confusion.

1 . DB on server
2. Process scripts on server
3. Pass parameters to client app and open file (by running the BAT)

This is the correct order.
In the last code example I did post the file would be stored on “c:\” . The reason for this is that the webmaster has not enabled a directory on the web server for read/write use because of his absence. When this is done I can store the BAT file on the server.
So when I understand it right, encapsulate the code in <% %> will still let it work, but this time on the server side. So now we can work on the questions I had in my last posting. So as we in Holland say, I think now our noses are pointing in the same direction.

 




Stuey -> RE: Send a parameter from a website to a application (1/21/2002 5:24:27)

This may sound like a really silly suggestion but you can call access as a dll from client side script

it's alread registered on your computer or should be

set fred = create.object(msaccess)
fred.open ........................

we do it with word, there are some very good knowledge base documents available



Stuart Steele
stuart@stuweb.co.uk
http://www.stuweb.co.uk




JeroenDortmans -> RE: Send a parameter from a website to a application (1/21/2002 6:43:52)

Hi Stuey,

What I want is to open an application and also send a parameter (drawing number) to this application so it will open this application and also returns a drawing to view. This drawing number comes from a database, so it is its value is dynamic.

 




rdouglass -> RE: Send a parameter from a website to a application (1/21/2002 12:30:50)

Sorry havent been here in a few days - family commitments...

Anyways, it sounds like you're looking for alternatives. Thats good - there more than likely a better solution out there. However the code I gave you above DOES work - I've tested it on my server. The main issue I think were stuck on is where to run the code. (This will probably spin off a thread or two of it's own...) It does run at the server which IMO is best for consistency sake... It does pass the .bat file to the client. The client does respond appropriately to the .bat file. You do need to give the web browser user (usually something like IUSR_[machine_name]) read/write access to the folder you're storing the /bat files in, so it may not be the best solution. For an Intranet, I think quite acceptable....

If you can get hold of you're web admin and create the folder / access for you, you may find this a quite workable solution. If read/write access is not an option, you may need to run the code at the client.

That's OK and still can be done, I would just approach it differently. Sorry for the confusion...

 

Edited by - rdouglass on 01/21/2002 12:32:49




JeroenDortmans -> RE: Send a parameter from a website to a application (1/21/2002 17:54:13)

Hi,

The read write permission is no problem. This will be done soon. I did modify the script and also made the path to the server for the server side script relative. I can’t test it at this moment, so I don’t know if it will work. The path to the server is good, this I can see with the “Response.write ServerPath” action. The response from the browser is something like “no permission”. So I think this has something to do with the read write permission.
Now I must try to write the parameter from the database into the file (DrawingNrVar).
I also tried this script at home. I use FP 2002 on Windows XP with IIS 5.1. Other ASP pages with database connection work fine, but when I try this script the server hangs itself up. Any idea? Here is the script.

<%
DIM Path_BAT, DrawingNrVar, ComplPath, ServerPath
Path_BAT = "\\IS0001\Shared_Apps\DAF_Progs\Trace2\TraceDirectView"
DrawingNrVar = "Drawing_number"
ComplPath = Path_BAT + " " + DrawingNrVar
ServerPath = Server.MapPath("Temp_BAT_file\View_VOG.BAT")
Response.write ServerPath

DIM filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile (ServerPath)
path = filesys.GetAbsolutePathName (ServerPath)
getname = filesys.GetFileName(path)
filetxt.WriteLine ("echo off")
filetxt.WriteLine (ComplPath)
filetxt.WriteLine ("exit")
filetxt.Close
%>

 




rdouglass -> RE: Send a parameter from a website to a application (1/22/2002 9:19:30)

Your code looks fine. Don't know why it would hang. That exact code worked fine on my server - WinNT4, IIS4.

A couple of things to check:

1. Do you have a folder named "Temp_BAT_file" at the root web of your server? Your script is looking to create the .bat file in that directory.

2. Do you have read/write permissions to that folder?

As I said, this script worked fine on my server - created the .bat file fine. Check those two things and we'll go from there.

I think once that is done, it is as you said, "to write the parameter from the database into the file (DrawingNrVar)"



 




rdouglass -> RE: Send a parameter from a website to a application (1/22/2002 10:51:40)

OOPS. Just found out maybe why you can't run it on your XP system:

http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=180

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/23/2002 14:07:49)

Hi Roger,

I have been trying to enable running the script on my PC but it still crashes my IIS 5.1. You must know I use Windows XP pro with IIS 5.1. Thanks for sending the link to an article, but this one was about XP home and the use of IIS. I posted a message at the “Server Issues” forum and Caywind suggested that the script would be in a loop, and thereby did hang my IIS.
To test the script I did past the code in a new ASP page and uploaded it to my own server. So I don’t so why this script would loop. And you tolled me it did work on your IIS4, so I find this very strange. Do you see anything what would bring this script in a loop?

 




rdouglass -> RE: Send a parameter from a website to a application (1/23/2002 14:49:31)

I don't see any loops...did you double check your permissions??

Here is a reference to a MS article on FSO's using JScript instead of VBScript. One interesting point on this article is they reference Win 2K Server, Advanced Server, and Pro - NOT XP at all!! Not any flavor of XP. I dunno' if this will help, but unfortunately I don't have a IIS 5.1 platform set up for testing...

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q299871&ID=KB;EN-US;q299871

Anyone out there have one they want to try this script on to confirm or deny IIS 5 functionality???

 




JeroenDortmans -> RE: Send a parameter from a website to a application (1/28/2002 16:14:06)

Hi,

I had to work on some other things for a few days, but now I can work on this script again. It now works on the IIS 4 server. I am still investigating why the script doesn’t work on my IIS 5.1 server, but it looks like the “CreateObject("Scripting.FileSystemObject")” isn’t supported on IIS 5.1. I still don’t know if it works on IIS 5 from Win 2000 Pro. But that’s another story.
The page from where I want to run this script is a result page of a search. There is only one “Drawing_number” on this page. Now I am looking for getting the database value from “Drawing_number” into the BAT file. I also want to run the script when some one clicks on this “Drawing_number” and after that “run” the BAT file. How to do this?

 




rdouglass -> RE: Send a parameter from a website to a application (1/30/2002 10:07:39)

Sorry, I've been away also...

Here is the complete code of a page I built. It has some of your code and some of mine. This page automatically sends the .BAT file to the browser (in a new window to keep the current one open) and uses a parameter from a test DB I use. I also used the DRW on a diet. I will try to hilite the specific things you'll need to change:

<html>

<head>

<SCRIPT type="text/javascript" language="JavaScript">
<!--
function open_window(url) {
mywin = window.open(url);
}
// -->
</SCRIPT>
<title>BAT Test Page</title>
</head>

<body>
<!--#include file="_fpclass/fpdblib.inc"-->
<%

'MY TEST DRW CODE ON A DIET

fp_sQry="SELECT * FROM Cars WHERE (RecordID = ::RecordID::)"
fp_sDefault="RecordID=5"
fp_sNoRecords="No records returned."
fp_sDataConn="colorTest"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=1
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="_fpclass/fpdbrgn1.inc"-->

<%

'YOUR CODE INSERTED INTO DRW

DIM Path_BAT, DrawingNrVar, ComplPath, ServerPath
Path_BAT = "\\IS0001\Shared_Apps\DAF_Progs\Trace2\TraceDirectView"

'NEXT LINE YOU WOULD REPLACE WITH YOUR FP FIELD

DrawingNrVar = FP_FieldVal(fp_rs,"RecordID")

ComplPath = Path_BAT + " " + DrawingNrVar
ServerPath = Server.MapPath("Temp_BAT_file\View_VOG.BAT")
Response.write ServerPath

DIM filesys, filetxt, getname, path
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.CreateTextFile("G:\inetpub\wwwroot\bats\View_VOG.BAT", True)
path = filesys.GetAbsolutePathName("G:\inetpub\wwwroot\bats\View_VOG.BAT")
getname = filesys.GetFileName(path)
filetxt.WriteLine ("echo off")
filetxt.WriteLine (ComplPath)
filetxt.WriteLine ("exit")
filetxt.Close
%>
<!--#include file="_fpclass/fpdbrgn2.inc"-->

'SEND THE BAT TO THE BROWSER

<SCRIPT language="JavaScript">
open_window('/bats/View_VOG.BAT')
</script>

</body>

</html>

Again this is running on a WinNT / IIS4 server. Hope this helps...

 




JeroenDortmans -> RE: Send a parameter from a website to a application (2/1/2002 2:07:21)

Hi Roger,

After I did place the script on a separate page, it worked fine. I modified the "drawing number" as displayed on the search result page into a hyperlink which links to a page where our "write BAT file" scripts runs. I open the "write BAT file" scripts in a new window. With the link I send the drawing number so a DRW on the "write BAT file" page grabs it so I can use it in the script for writing the BAT file and after that close this new window. This all work fine. For making this process faster, I want to open the new window with no menubar, statusbar, toolbar en so on. I must specify this with the link on the search result page. I now how to do this in JavaScript, but now I also want to send the variable "drawing_number" with it. I thought on something like this:
<SCRIPT language="JavaScript">
function popIt(parameter)
{
var url = "Write_BAT.asp?Drawing_number=;
var x = window.open(url,'popWin','status=no,toolbars=no,width=100,height=100');
x.moveTo(50,50);
}
</script>
<a href="javascript:popIt(<%=FP_FieldURL(fp_rs,"Drawing_number")%>);">
It needs some fine-tuning because it gives some error's. Any idea?




rdouglass -> RE: Send a parameter from a website to a application (2/4/2002 8:10:55)

How about something like this:

(This should be in the <HEAD> section)

<SCRIPT language="JavaScript">
function popIt(url)
{
myPopItWin = window.open(url,'popWin','status=no,toolbars=no,width=100,height=100');
x.moveTo(50,50);
}
</script>

Then, this part needs to be within your DRW:

<a href="javascript:popIt('Write_BAT.asp?Drawing_number=<%=FP_FieldURL(fp_rs,"Drawing_number")%>')">

When the user clicks on the link (directly above), they should open the .BAT in a new window with your spec's.

**Haven't checked any of it for syntax errors, etc. Hope it helps...

 




JeroenDortmans -> RE: Send a parameter from a website to a application (2/5/2002 4:42:40)

Hi Roger,

It works after I did modify it a little. So that is the "writing BAT" file part.
Now I am working on the part that there can be 2 different "Path_BAT" depending on the user works on a CAD station or a PC. When the user visits the site, he must be asked weather he is working on a CAD station or a PC. I was thinking of writing a cookie with this information and when the site is accessed, reading this cookie to determine weather the user is on a CAD system or a PC. This way I don't have to bother him with this question again. The only problem is that the user information is on a network disk. So the cookies are written to this same network disk. When for example the user switches from a PC to a CAD system the site could think he works on a PC when he is working on a CAD system. When the link to view the drawing is clicked the BAT file is made with the wrong path to the application to view the drawing.
Is there a way to force the cookie to be written on a local disk (C:\Windows\Cookies)? That will solve the problem.




rdouglass -> RE: Send a parameter from a website to a application (2/5/2002 12:37:13)

Nope, AFAIK you (the web developer) don't get to pick the location that the cookie saves to...

Why couldn't you set the cookie with no expiration date defined. Then (IIRC) it will expire when the browser is quit. Reset the cookie on next login. Will that work???

EDIT: The other option may be to check the browser stats on login (OS, etc.) and pick the cookie based on that...

Edited by - rdouglass on 02/05/2002 12:38:39




JeroenDortmans -> RE: Send a parameter from a website to a application (2/7/2002 3:05:22)

Hi Roger,

I am going to use "CreateObject" again. This time to solve that cookies are written on a personal network drive instead of on the computer itself. As I mentioned in my last posting, there is a difference in path for PC and CAD system users to start the drawing viewer. To determine whether the user works on a PC or a CAD system I prompt a small page with this question. When he or she answers on this question I want to create a txt file on the C drive which indicates that it is a PC or a CAD system. When the wesite is used in a new session, it must first search for this txt file to determine whether the user works on a PC or a CAD system. As a result of that the website knows which page must be started. When this txt file isn't there, the "make txt file page" must be started.
I did some testing with a client side "CreateObject" script. This script will prompt an IE warning that an ActiveX component is used. That's no problem. However, I don't want to have this warning when reading this txt file. I know this is a setting of IE, but I want to leave these settings for what they are. I think that any further questions about this should be in a new posting.
So from here I want to thank you Roger for all your help with "creating a BAT file on the server". I did learn a lot from it and appreciate your patience. Thank you, thank you, thank you!!!
By the way, I did nail that my IIS 5.1 webserver did crash when running the "create BAT file" script. It was my Norton Antivirus 2002. It blocks scripting which causes my webserver to crash. This can be solved by disabling this option in Norton Antivirus 2002. See this link http://www.iisfaq.com/Articles/387/Default.asp?Print=1

 




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.203125