Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I cannot link a .VBS File with Parameter

Status
Not open for further replies.

sa5cha

Programmer
May 29, 2001
34
DE
Hi,

may someone help me with this ?

I use a W2KServer with IIS 5 on it.

I wrote some VBS-Service-Scripts, you can start them with parameters in the command box, like that:

ChangePW.vbs John.Doe

Then the User with the Login "John.Doe" would get a new password for his account.

I'd like to run the scripts from my ASP Intranet page, but it doesnt works.

<a href="vbsscripts/ChangePW.vbs JohnDoe">Link</a>
would transform in somthing link this:
<a href="vbsscripts/ChangePW.vbs%20JohnDoe">Link</a>

and the parameter wont work.

What am I doing wrong here ? Any Ideas ?

Thanks
Sascha



 
Try creating an instance of the shell and running your command line that way.

Also, do you want the script to run on the server or browser client machine?
 
Well . . ., strings that can be interpreted by an operating system when entered on a command line are not URLs; and requests for a file identified by a URL are not interpreted by the operating system, they are interpreted by the web server.

So. The .vbs file must be executed from within the ASP script by starting an instance of the operating system command interpreter, command.com, and providing it with the name of the file and any parameters the file will need. In PerlScript, one might write
Code:
...
system "vbsscripts/ChangePW.vbs JohnDoe";
...

And one might provide that to the ASP script using the querystring -
Code:
...
<a href="run_this.asp?filename=ChangePW.vbs&parameter_one= JohnDoe">Link</a>
...


Within the ASP you obtain the file name and parameter from the querystring, then pass them as arguments to the function which starts command.com. Sorry I cannot recall the name of that function in VBScript. As I said the function is named system() in PerlScript.
 
Sorry for the delay and thank you for your help.

I found a solution for my problem:

here is the code for the ASP/HTML Page:

Code:
<html>
<head>
<SCRIPT LANGUAGE=vbscript>
sub div1_onclick()
   Set oW= CreateObject("WScript.shell")
   'Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
   oW.Run "C:\tmp\my.vbs Param1 Param2", 1, True
   Set oW = Nothing  
   msgbox "A"
end sub
</SCRIPT>

<SCRIPT LANGUAGE=vbscript>
sub div2_onclick()
   Set oWs= CreateObject("WScript.shell")
   'Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
   oWs.Run "\\myserver\$hiddenshare$\my.vbs Param1 Param2", 1, True
   Set oWs = Nothing  
   msgbox "A"
end sub
</SCRIPT>
</head>

<body>
<!-- executing the DIVs click event and calling the VBS -->
<DIV id="div1" name="div1">
<a href="p.htm">click event on DIV tag</a>
</DIV>

<DIV id="div2" name="div2">
<a href="p.htm">click event on DIV2 tag</a>
</DIV>
</body>
</html>


and here is the code for the VBS file:

Code:
Dim ArgObj ' Object which contains the command line argument
Dim Args(999) ' Array that contains all of the non-global arguments
Dim ArgCount ' Tracks the size of the Args array

Dim i

' Get the Arguments object
Set ArgObj = WScript.Arguments

' Test to make sure there is at least one command line arg - the command
If ArgObj.Count > 0 Then
    For i=0 to ArgObj.Count-1
        Msgbox ArgObj(i)
    Next
End If

MsgBox "quit"

WScript.Quit


I found this very nice.I am able now to administer some things through my intranet page using my VB scripts.

Sascha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top