Download a file using Javascript
Actually, if you want a ‘more-efficient’ (and sexier) way, use: location.href = your_url; That way, you will save the compiler some time in going up to the location‘s prototype chain up to the window object.
Actually, if you want a ‘more-efficient’ (and sexier) way, use: location.href = your_url; That way, you will save the compiler some time in going up to the location‘s prototype chain up to the window object.
Your code should look like this:- Function GetTextFromUrl(url) Dim oXMLHTTP Dim strStatusTest Set oXMLHTTP = CreateObject(“MSXML2.ServerXMLHTTP.3.0”) oXMLHTTP.Open “GET”, url, False oXMLHTTP.Send If oXMLHTTP.Status = 200 Then GetTextFromUrl = oXMLHTTP.responseText End If End Function Dim sResult : sResult = GetTextFromUrl(“http://www.certigo.com/demo/request.asp”) Note use ServerXMLHTTP from within ASP, the XMLHTTP component is designed for client side usage and … Read more
You’ll want to use the GetExtensionName method on the FileSystemObject object. Set x = CreateObject(“scripting.filesystemobject”) WScript.Echo x.GetExtensionName(“foo.pdf”) In your example, try using this For Each objFile in colFiles If UCase(objFSO.GetExtensionName(objFile.name)) = “PDF” Then Wscript.Echo objFile.Name End If Next
There is no way to convert a VBScript (.vbs file) into an executable (.exe file) because VBScript is not a compiled language. The process of converting source code into native executable code is called “compilation”, and it’s not supported by scripting languages like VBScript. Certainly you can add your script to a self-extracting archive using … Read more
A callable piece of code (routine) can be a Sub (called for a side effect/what it does) or a Function (called for its return value) or a mixture of both. As the documentation for MsgBox, Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating … Read more
It turns out to get this application working under VBScript, I had to do two things. Run RegAsm.exe to register the DLLs. Run the C:\Windows\SysWOW64\cscript.exe to run my VBScript. If these don’t work, check out the other answer here about enabling 32-bit applications in IIS.
Run cscript.exe for full command args, I think cscript //X scriptfile.vbs MyArg1 MyArg2 will run the script in a debugger.
Set args = Wscript.Arguments For Each arg In args Wscript.Echo arg Next From a command prompt, run the script like this: CSCRIPT MyScript.vbs 1 2 A B “Arg with spaces” Will give results like this: 1 2 A B Arg with spaces
VBScript GetObject documentation can be found here. Here is a VBScript sample: Set objExcelFile = GetObject(“C:\Scripts\Test.xls”) WScript.Echo objExcelFile.Name objExcelFile.Close This code will get you the Excel Workbook object contained in C:\Scripts\Test.xls. You can use TypeName() to confirm that: Set objExcelFile = GetObject(“C:\Scripts\Test.xls”) WScript.Echo objExcelFile.Name WScript.Echo TypeName(objExcelFile) objExcelFile.Close The output will be: test.xls Workbook If the … Read more
WScript.Shell.Exec() returns immediately, even though the process it starts does not. If you try to read Status or StdOut right away, there won’t be anything there. The MSDN documentation suggests using the following loop: Do While oExec.Status = 0 WScript.Sleep 100 Loop This checks Status every 100ms until it changes. Essentially, you have to wait … Read more