Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Client VBS - Getting POST & Get variables

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,38969
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Client VBS - Getting POST & Get variables
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Client VBS - Getting POST & Get variables - 10/20/2006 8:41:34 AM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline
Hi there, I am building a small client-side vbs script which when called via a html page will run a program passing all the page variables to it. e.g.

 Set WshShell = CreateObject("WScript.Shell")
  WshShell.CurrentDirectory = "c:\PHP\"
Set oExec = WshShell.Exec("cmd /c" & cProgram & "username=username password=password ...")


First of all I don't know how to get the page variables from the master html page. I know how to do it under asp but it doesn't work for vbs.

Secondly I need to be able to produce a string of all the variables past in the

mystring = "name=value name2=value2 name3=value3    etc. etc."

format.

Could anyone help with this?

BTW, no server side scripting can be used for this as this web page is intended to be run locally on individual user's machines. Any help would be much appreciated.





_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk
 
 
Post #: 1
 
 RE: Client VBS - Getting POST & Get variables - 10/20/2006 11:49:55 PM   
  TNO


Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
Mind posting the HTML code and the vbs code?

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to swiftoid)
 
 
Post #: 2
 
 RE: Client VBS - Getting POST & Get variables - 10/20/2006 11:55:09 PM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline
This is a very awkward hack to avoid using a web server but still display code. I would like to build a Visual Basic Program to host the html output and call PHP but I wouldn't know where to start.
Code still not finalized but something like this:

HTML Page:
-------------------
<SCRIPT LANGUAGE="VBScript" src="vb_file.vbs"></script>

VBS file:
-------------------
Function RunOutput(cProgram, nWindowType)

Dim oFS
Set oFS = CreateObject("Scripting.FileSystemObject")
'-- Execute the command and redirect the output to the file
Dim oShell
Dim MyPath
MyPath = "C:/PHP/"
Set oShell = CreateObject("WScript.Shell")
oShell.CurrentDirectory = "c:\fmo\"
oShell.Run "COMMAND /c " & cProgram & " > c:\fmo\temp.txt", True
Set oShell = Nothing

Dim oFile
'-- Read output file and return
Set oFile = oFS.OpenTextFile("c:/fmo/temp.txt", 1, True)
RunOutput = oFile.ReadAll()
oFile.Close

End Function
Dim outpt
outpt = RunOutput("php.exe -f c:/fmo/fmo/sindex.php", 1)
document.write (outpt)

------------------------------------
(The VBS code is still under construction as you can see)

The html page would be called like so:
file://c:/fmo/index.html?file=sindex.php&somevar=hello&somethingelse=another


Any help much appreciated.

< Message edited by swiftoid -- 10/21/2006 12:06:54 AM >


_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk

(in reply to swiftoid)
 
 
Post #: 3
 
 RE: Client VBS - Getting POST & Get variables - 10/21/2006 1:13:13 AM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline
Also I would really like to be able to get the contents of a shell command without having to save it to a file first. I came up with this:

Set WshShell = CreateObject("WScript.Shell")
  WshShell.CurrentDirectory = "c:\fmo\"
Set oExec = WshShell.Exec("cmd /c" & cProgram)

RunOutput = oExec.StdOut.ReadAll

But this opens the prompt up for a second while it runs.

_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk

(in reply to swiftoid)
 
 
Post #: 4
 
 RE: Client VBS - Getting POST & Get variables - 10/21/2006 6:30:02 AM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline

Yes, I came up with a solution to my original problem which was:
How to get the output of php.exe into internet explorer without using server side apps

so I decided to post it here for you guys to see but also to get some help with.

Here's how to run it. Make a directory at C:/fmo/
put php.exe and php4ts.dll in it
save the two files below and put them in as well

Finally make another directory inside it called fmo and past the php files you want to work there. Each link to a php file should be in the format of
index.html?fpovar=name_of_php_file.php&pagevars=value&someothervar=differantvalue
 


---------------------------
html file: index.html
---------------------------
<SCRIPT LANGUAGE="VBScript" src="vb_no_file.vbs"></script>
---------------------------
---------------------------
---------------------------
VBS File: vb_no_file.vbs
---------------------------
Function RunOutput(cProgram, nWindowType)

'-- Obtain a Temporary File Name
Dim oFS
Set oFS = CreateObject("Scripting.FileSystemObject")
'-- Execute the command and redirect the output to the file
Dim oShell
Dim MyPath
MyPath = "C:/PHP/"
Set oShell = CreateObject("WScript.Shell")
oShell.CurrentDirectory = "c:\PHP\"
oShell.Run "COMMAND /c " & cProgram & " > c:\php\temp.txt", True
Dim WshShell
Dim test
Set WshShell = CreateObject("WScript.Shell")
WshShell.CurrentDirectory = "c:\fmo\"
Set oExec = WshShell.Exec("cmd /c" & cProgram)
'Set oExec = WshShell.Run("COMMAND /c " & cProgram)
RunOutput = oExec.StdOut.ReadAll
Set oExec = Nothing
Set WshShell = Nothing
End Function
''''''''''''
dim search, pgname, leng
search = location.search
if search <> "" AND search <> "?" then
pos=Int(InStr(search,"=")+1)
pos2=Int(InStr(search,"&"))

if pos2 = 0 then
pos2 = len(search) + 1
end if

leng=Int(pos2-pos)

if pos >= 1 AND leng > 0 then
'pgname = Mid(search,pos,leng)
pgname = Mid(search,pos,leng)
end if

search = replace(search, "&", " ", 1, -1, 1)
search = replace(search, "?", "", 1, -1, 1)
else
pgname="sindex.php"
end if
'''''''''''''''
Dim outpt
document.write (mystrg)
outpt = RunOutput("php.exe -f c:/fmo/fmo/" & pgname & " " & search, 1)
document.write (outpt)
---------------------------
---------------------------
It still has a couple of faults though:
1. Every time you load a php file a comand prompt appears for a second then dissapears
(if I use Run instead of Exec this doesn't happen but it always stores to a file)
2. Each time vbs runs the command prompt a security alert appears

The first one is resolvable but I don't know what to do about the other. I tried making my own Visual Basic Browser but the alerts still appear. Any help much appreciated.


_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk

(in reply to swiftoid)
 
 
Post #: 5
 
 RE: Client VBS - Getting POST & Get variables - 10/21/2006 8:04:22 PM   
  TNO


Posts: 1397
Score: 16
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
1. Not guaranteed but try this:  oShell.Run "COMMAND /c " & cProgram & " > c:\php\temp.txt",0, True this SHOULD run the window hidden.
2. rename your html file to .hta


< Message edited by TNO -- 10/21/2006 8:06:59 PM >


_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to swiftoid)
 
 
Post #: 6
 
 RE: Client VBS - Getting POST & Get variables - 10/22/2006 1:52:04 AM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline
Cool, thanks for that. I never heard of hta before. I still have some questions though.

About the running the command as oShell.Run. I Have tried this already but my problem witht this is that by the time the file is written the code to read it has already run and it ends up that it is readying the last file called. I thought of using sleep but this seems to just completely stop the program. Can you help with using sleep?


When I renamed it to this it would open up the default file as specified in the script I posted above but each link opens up in internet explorer as a download of a hta file.
So I have the following changes to your recomendation:

file: index.hta
----------
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=file://c:/fmo/index.html?file=sindex.php" >
---------

I kept index.html the same as above

so that it opens up sindex.php . However all the links on this page open up internet explorer and give the same problem.

Is it not possible to browse within a hta file. As I say I have not experience with this format. Please help

_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk

(in reply to TNO)
 
 
Post #: 7
 
 RE: Client VBS - Getting POST & Get variables - 10/22/2006 2:25:02 AM   
  swiftoid


Posts: 31
Score: 0
Joined: 10/20/2006
Status: offline
Hey, I should really do my research before posting here. Since my last post I have managed to fix all the links problems mentioned at the bottom of my last post. However I still could you some help with this:

About the running the command as oShell.Run. I Have tried this already but my problem with this is that by the time the file is written the code to read it has already run and it ends up that it is readying the second last file called. I thought of using sleep but this seems to just completely stop the program. Can you help with using sleep?

_____________________________

Jamie Swift
<!---The Swiftanator---!>
www.swiftscripts.co.uk

(in reply to swiftoid)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Client VBS - Getting POST & Get variables Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts