I am getting error in scheduled task :"http://localhost:4625/DataUpdater.aspx.Error Message:Object reference not set to an instance of an object."
Scheduledtask vbs script :
Call LogEntry()
Sub LogEntry()
On Error Resume Next
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
URL = "http://localhost:4625/DataUpdater.aspx"
objRequest.open "POST", URL , false
objRequest.Send
Set objRequest = Nothing
End Sub
If the error is coming back from Cassini/IIS then you should post the code in the .aspx / .aspx.cs file, and the line the error is occurring on.
Have you tried to use a batch file to do this?
For example here are some sample run lines:
cscript.exe c:\scripts\call_logs.vbs
Or:
script.exe c:\scripts\call_logs.vbs
Here is one that I use to archive off IIS Logs:
C:\WINDOWS\system32\wscript.exe D:\scripts\list.vbs
Related
This question already has answers here:
Download a file with VBS
(6 answers)
Closed 3 years ago.
Is it possible to download a file in intervals from a specified URL to a specified location in an easy way?
I created VBScript:
Set args = WScript.Arguments
path = ""
datePath = ""
Url = ""
dim filesys
Set filesys = CreateObject("Scripting.FileSystemObject")
Do
If filesys.FileExists(path) Then
filesys.DeleteFile path
End If
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", Url, False
xHttp.Send
with bStrm
.type = 1 '//binary
.open
.write xHttp.responseBody
.savetofile path, 2 '//overwrite
end with
If(xHttp.Status = 200) Then
If filesys.FileExists(datePath) Then
filesys.DeleteFile datePath
End If
Set dateFile = filesys.CreateTextFile(datePath)
dateFile.WriteLine(FormatDateTime(Now))
dateFile.close()
End If
WScript.Sleep 600000
Loop
But it doesn't work as it returns following prompt:
This page is accessing information that is not under its control. This
poses a security risk. Do you want to continue?
I tried to disable notification by changing internet options but it also doesn't work for me.
I need the script to work even when I am absence in my job thus I need to improve/change this to be maintenance-free. It also needs to work on Windows OS.
I also tried to use powershell > wget but then authentication problem occures as file i need to get is in secured business's infranet and need to use my login credentials I tried to provide them in URL or as wget arguments --user/-password - It doesn't work because login procedure requires redirections. VBScript uses my current session thus infranet security system allows it to get in.
Is anyone able to help with my problem?
Add a task in Task Scheduler with whatever schedule you like, and in the action, add this:
start a program: Powershell
argument: wget URL -OutFile FILEADDRESS
I am trying to run a VBScript but CFExecute throws an error
<cfexecute name = "C:\Windows\System32\CScript.exe"
arguments = "//NoLogo D:\Excel.vbs D:\test.xls"
variable = "data"
timeout = "100">
</cfexecute>
<cfdump var="#data#">
Error:
Error: 424 Source: Microsoft VBScript runtime error Description: Object required
But when I run the VBScript with CMD it works fine
C:\Windows\System32 > cscript //nologo D:\Excel.vbs D:\test.xls
I have full admin access, so why am I getting this error?
It was due to bug in the Windows 2008 server.
For office automation (accessing via script and non-window based operation) we have to add a "Desktop" folder inside
C:\Windows\System32\config\systemprofile
C:\Windows\SysWOW64\config\system32
I added it and found success.
Create a vbscirpt file (.vbs). The code content would have the task you want to achieve.
The below example contains the vbscript file, that refreshes the excel and the cfm which executes the vbscript.
Sample vbscript file code:-
Set fso = CreateObject("Scripting.FileSystemObject")
Set xl = CreateObject("Excel.Application")
xl.Visible = True
For Each f In fso.GetFolder("C:\inetpub\WebSites\Upload\").Files
If LCase(fso.GetExtensionName(f.Name)) = "xlsx" Then
Set wb = xl.Workbooks.Open(f.Path)
wb.RefreshAll
wb.Save
wb.Close
End If
Next
xl.Quit
Sample cfm file code:-
<cfexecute name = "C:\Windows\System32\cscript.exe" arguments = "C:\inetpub\WebSites\CSAT\test.vbs">
</cfexecute>
I have windows hosting and it uses plesk. I want to make http request in every 30 mintues. I have written a vbs script to do this. Below you can see the code. But I am wondering what to write in "Path to executable file" field.
Also I set "Arguments" field as /httpdocs/scripts/web_visit_script.vbs
Here is vbs file code:
Call Send_HTTP_Request()
Sub Send_HTTP_Request()
'Force the script to finish on an error.
On Error Resume Next
'Declare variables
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Put together the URL link appending the Variables.
URL = "http://www.google.com"
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
'Send the HTML Request
objRequest.Send
'Set the object to nothing
Set objRequest = Nothing
End Sub
Technically c:\windows\syswow64\cscript.exe should be enough as the path to the executable. If that is not enough then I recommend making a .bat file in that scripts folder with the following code: c:\windows\syswow64\cscript.exe web_visit_script.vbs and then simply call that .bat file in the path to executable with no arguments.
Thanks,
Sean W.
I have set up the following Sub to run shell commands quickly and easily.
This script works for the login scripts at my company without fail.
I am currently developing a script to add a large batch of users to our domain.
When I used this Sub in my new script I receive an error saying that the file cannot be found.
I have tried using the fix in this stackoverflow post, but I recieve the same error even with this code.
VBScript WScript.Shell Run() - The system cannot find the file specified
The part I find puzzling is that this sub works just fine when run from the netlogon folder of our domain controller.
What am I doing wrong?
Thanks,
Sub runcommand(strCommand)
Dim objWshShell, intRC
set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run(strCommand, 0, TRUE)
call reportError(intRC,strCommand)
set objWshShell = nothing
end Sub
function reportError(intRC, command)
if intRC <> 0 then
WScript.Echo "Error Code: " & intRC
WScript.Echo "Command: " & command
end if
end function
The previous values for strCommand had no spaces and were very straightforward. Your new script is passing more complex variables to your Sub so you need additional conditional handling, as Alex K. pointed out in his Collusion (i.e., "Comment/Solution") above. Alex K.'s sample above is perfect, so, being a Point Pimp tonight, will post it as the solution:
objWshShell.Run("cmd /k echo Hello World", 1, TRUE)
hopefully this will be an easy one? I've got a VBS file which I am trying to schedule every week to do a XML refresh. It simply calls an ASPX page. But I cannot get the thing to work! Even when I try to double click the VBS file I just get an error message. The actual code can be found all over the place - it seems to be standard code for this purpose.
The code is (fetch.vbs)
Call LogEntry()
Sub LogEntry()
'Force the script to finish on an error.
On Error Resume Next
'Declare variables
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Put together the URL link appending the Variables.
URL = "http://mywebsite/fetchXML.aspx"
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
'Send the HTML Request
objRequest.Send
'Set the object to nothing
Set objRequest = Nothing
End Sub
The error message I get from windows (when I double click the VBS file is)
Script: fetch.vbs
Line: 1
Char: 1
Error: Invalid Character
Code: 800A0408
Source: Microsoft VBScript Compilation Error
Any ideas?!
Problem was solved by saving as ANSI format (not UTF-8 as default)
ref: VBScript Invalid Character 800A0408 compilation error
it looks like it may be the encoding. especially for line 1 char 1.