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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open POST request in a browser using vbscript

Status
Not open for further replies.

senlog80

Programmer
Aug 23, 2016
4
DE
I need to open a POST request in a browser using vbscript.

I can open the browser using GET request by the following commands

Set objWShell = CreateObject("WScript.Shell")
objWShell.Run AddQuotes(url)
But I don't know how to do this for POST request. I have tried the following script, but it do the task silently. It doesn't open the browser.

Set xHttp = CreateObject("MSXML2.XMLHTTP")
xHttp.open "POST", " False
xHttp.send paramList
Can anyone help me here.

Thanks
Senthil
 
It doesn't open the browser.

It won't, it ONLY requests the content from that URL and stores in the .responseXML property.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
ok, I have written my POST request into a html file and called that html file from the vbscript.
In this way, it is working.

But here, the file is accessible to everyone. I want to delete the file after the browser is opened.
I have used the following script.

objWShell.run fileString
subSleep(120)
If objFS.FileExists (fileString) Then
objFS.DeleteFile (fileString)

But within 2 seconds, if someone access the file, it is a security issue. If we remove the sleep the browser is not opening.
The command "objWShell.run fileString, 1, true" is working except for the case, the popup blocker is on.

So, Is there any way to allow the popup blocker for the specified website alone using vbscript?

Thanks
Senthil
 
So, Is there any way to allow the popup blocker for the specified website alone using vbscript?

Nope, for obvious reasons such controls are ONLY accessible by the user.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
ok, Is there any way atleast to check whether the Popup blocker is enabled or not using vbscript

Thanks
Senthil
 
Only if you want to get into some vbscript registry hacking. (Assuming that every user is on MS Windows and using Infernet Exploder and you can 'plant' the script on their machine)


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Something like the following might help:

Code:
[blue]    Set xHTTP = CreateObject("MSXML2.XMLHTTP")
    xHTTP.Open "POST", "[URL unfurl="true"]http://www.example.com/",[/URL] False
    xHTTP.send ParamList
    
    Set myIE = CreateObject("InternetExplorer.Application")
    myIE.Visible = 1
    myIE.Navigate "about:blank" ' make sure we have a page
    myIE.Document.body.outerhtml = xHTTP.responseText[/blue]
 
Thanks for the script. I tried the same with my code.
But, this is not working when I have the post parameters in the following format

ParamList = """lang=en&adLocation=CN=hello767 hello767,OU=chennai,OU=India,DC=India-Telecom,DC=com&givenname=hello767"""

Set xHTTP = CreateObject("MSXML2.XMLHTTP")
xHTTP.Open "POST", " False
xHTTP.send ParamList

Set myIE = CreateObject("InternetExplorer.Application")
myIE.Visible = 1
myIE.Navigate "about:blank" ' make sure we have a page
myIE.Document.body.outerhtml = xHTTP.responseText

I am not getting the post parameters.
 
Try adding

Code:
[blue]xHTTP.setRequestHeader "Content-type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
xHTTP.setRequestHeader "Content-length", Len(ParamList)[/blue]

before the .Send line
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top