I'm getting the following error:
Access violation at address 00406017
in module 'msched.exe'. Read of address 6E3A6E6A
Occurs very intermitently.... and I'm usually not around to see it happen.
This is happening in the new 10.1.18 version.
Just wondering if anybody else has seen this before? It will be
very hard to track down as I've only seen it twice, and both times it's been after I've returned to the computer after MS has been running many long running macros.
Thanks.
Access violation at address 00406017 in module 'msched.exe'.
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This is most likely being caused by something one of your macros is doing. Please enable logging for all your macros. Then next time the error occurs, grab a copy of your log file(s) before doing anything else and note down which macro is running/was last running. We need to work out what line(s) in your script is causing this.
If you have any CreateObject VBScript lines are you freeing those objects afterwards (setting them to Nothing)?
Feel free to post your scripts or send them to support and we'll take a look and see if we can spot anything obvious.
If you have any CreateObject VBScript lines are you freeing those objects afterwards (setting them to Nothing)?
Feel free to post your scripts or send them to support and we'll take a look and see if we can spot anything obvious.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Assigned causes Access Violation ?
Update:
Well, I looked at the log of the run it was making when apparently the access violation happened, and I believe I found what it was running when the error occured.
I believe the access violation probably happened when it was doing the "Assigned>" statement. Then nothing happened until I closed MS and restarted it. It then logged the next line at 7/29/2008 13:10:05:531. The gap of 37 minutes was while the error box was on the screen.
Hope this gives you some clue Marcus..... Thanks!
Well, I looked at the log of the run it was making when apparently the access violation happened, and I believe I found what it was running when the error occured.
I believe the access violation probably happened when it was doing the "Assigned>" statement. Then nothing happened until I closed MS and restarted it. It then logged the next line at 7/29/2008 13:10:05:531. The gap of 37 minutes was while the error box was on the screen.
Code: Select all
7/29/2008 12:33:07:109 - Assigned>V_CLONENUM,V_CLONENUMExists
7/29/2008 13:10:05:531 - Started Macro : A Case Management Master
7/29/2008 13:10:05:531 - // ***********************************************************
Marcus,
I'm running into this same Access Violation issue with EXE's in 10.1.17. The Assigned> statement is causing the Access Violation message when executing the EXE but doesn't happen when its not an EXE.
I haven't been able to figure out exactly what triggers the problem though. The script that has the issue is 800 lines long and is doing a lot of stuff. When I make shorter scripts to try to narrow it down the Assigned> statement seems to work ok in the EXE. Maybe the problem is related to the length of the script?
The script which is causing the problem is listed below. When this script is compiled and the Access Violation occurs right away and every time at line 670. When run a message is popped just before the Assigned> statement is executed.
Hope this helps in some way.
Warm regards,
Jim Palic
//Initialise VBScript
VBSTART
Function DeXml (strXML)
Dim regEx, Matches
Set regEx = New RegExp
regEx.Pattern = "]*>(.*)"
Set Matches = regEx.Execute(strXML)
If Matches.Count > 0 Then
DeXML = Matches(0).Submatches(0)
Else
DeXML = strXML
End If
Set Matches = Nothing
Set regEx = Nothing
End Function
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
'Navigates IE to specified URL
Sub Navigate(URL)
IE.Navigate URL
WaitBusy
End Sub
Sub WaitBusy
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = Nothing
End Sub
'Attaches to an existing instance of IE with matching URL
Function GetIE(giURL)
Dim objInstances, objIE
GetIE = False
Set objInstances = CreateObject("Shell.Application").windows
If objInstances.Count > 0 Then '/// make sure we have instances open.
For Each objIE In objInstances
If InStr(objIE.LocationURL,giURL) > 0 then
Set IE = objIE
GetIE = True
Exit For
End If
Next
End If
Set objIE = Nothing
Set objInstances = Nothing
End Function
'clicks specified link
Function ClickIt(elemText)
Dim elems
Dim ItemNr
ClickIt = False
Set elems = IE.document.getElementsbyTagname("input")
For ItemNr = 0 to elems.length - 1
'MsgBox elems.Item(ItemNr).value
If elems.Item(ItemNr).value = elemText Then
elems.Item(ItemNr).click
ClickIt = True
End If
Next
Set elems = Nothing
WaitBusy
End Function
'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
dim t
set t = IE.document.getElementsbyTagname(Tagname)
if all=1 then
ExtractTag = t.Item(Num).outerHTML
else
ExtractTag = t.Item(Num).innerText
end if
End Function
' DeleteG2ShortCut - get rid of leftover shortcuts
Sub DeleteG2Shortcut
Dim strDesktop
' Which folder has the desktop?
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
' Get a list of files in the desktop
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oDir = objFSO.GetFolder(strDesktop)
Set oFiles = oDir.Files
' Look at each file
For Each f In oFiles
sExt = UCase(objFSO.GetExtensionName(f.Name))
' Is it a link?
If sExt = "LNK" Then
' Is it a GoToMyPC shortcut?
If Left(f.Name, 11) = "GoToMyPC - " Then
objFSO.DeleteFile(strDesktop & "\" & f.Name)
End If
End If
Next
Set f = Nothing
Set oFiles = Nothing
Set oDir = Nothing
Set objFSO = Nothing
End Sub
VBEND
//---------------------------------------------------------------------
// Program Starts Here
// Messageboxes are on top of all windows
Let>MSG_STAYONTOP=1
//Get computer name
Let>compName=FLORCARTI
//Input>compName,Computer Name:
//---------------------------------------------------------------------
// Run connectivity tests to make sure we can get to ONLC.COM
Gosub>Connectivity
If>pingOK=N,End
//---------------------------------------------------------------------
//Ask webservice for url of GoToMyPC/GoToMeeting connection (based on computer name)
Let>desturl=http://www.onlc.com/webservices/cnifrna ... =%compName%
Gosub>CheckURL
If>urlOK=N,End
//---------------------------------------------------------------------
// Get text of response
// Clean response so we can pass to VB
StringReplace>urlResponse,",,strResp
StringReplace>strResp,CRLF,,strResp
// Strip XML stuff Off
VBEval>DeXml("%strResp%"),connUrl
//---------------------------------------------------------------------
// If return results in ERR show it and stop
MidStr>connUrl,1,3,strSub
If>strSub=ERR
MessageModal>%connUrl%
Goto>End
Endif
//---------------------------------------------------------------------
// If return results in MSG show it for a bit and then stop
MidStr>connUrl,1,3,strSub
If>strSub=MSG
Message>%connUrl%
Let>WW_TIMEOUT=60
WaitWindowClosed>Macro Scheduler Message
// Close the messagebox
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
Goto>End
Endif
Label>Cont1
Let>connUrl=http://www.onlc.com
// Need to know IE Version (full version is IEVerStr, major (6,7,etc) is IEVerMaj
Let>IEVerMaj=7
//RegistryReadKey>HKEY_LOCAL_MACHINE,Software\Microsoft\Internet Explorer,Version,IEVerStr
//MidStr>%IEVerStr%,1,1,IEVerMaj
//---------------------------------------------------------------------
// Need to know whether we're doing GoToMeeting or GoToMyPC
Let>g2pcName={""}
Position>gotomypc,connUrl,1,nPos
If>nPos>0
// Deduce GoToMyPC window name
Length>connUrl,nLen
Position>pc=,connUrl,1,nPos
MidStr>connUrl,{%nPos%+3},{%nLen%-%nPos%-2},g2pcName
StringReplace>g2pcName,%20,{" "},g2pcName
Endif
If>{Length(%g2pcName%)=0},GoToMeeting
//---------------------------------------------------------------------
// GoToMyPC Startup
Label>GoToMyPC
// Try to close other leftover windows
//GetWindowList>winList
//Separate>winlist,CRLF,windows
//Let>k=1
//Repeat>k
//Let>this=windows_%k%
//MessageModal>this
//Let>k=k+1
//Until>k>windows_count
// If the window is already open then assume we're good to go
IfWindowOpen>%g2pcName%*
Message>GoToMyPC %g2pcName% already open
Let>WW_TIMEOUT=15
GoSub>MSMsgClose
Goto>End
Endif
// Perform connect steps
GoSub>GoToMyPC_Connect
// Make sure it's open
Let>WW_TIMEOUT=20
WaitWindowOpen>%g2pcName%*
// If we're connected
If>WW_RESULT=TRUE
// Give the window a little time to settle down
Wait>5
// Delete old shortcuts
VBRun>DeleteG2Shortcut
// Make a new shortcut
Gosub>GoToPC_Shortcut
// Maximize the window
Gosub>GoToPC_Maximize
Else
// Some unexpected error occurred
Message>GoToMyPC %g2pcName% did not open!
Let>WW_TIMEOUT=60
GoSub>MSMsgClose
// Try again
Goto>GoToMyPC
Endif
// Done with GoToMyPC
Goto>End
//---------------------------------------------------------------------
// GoToMeeting Startup
Label>GoToMeeting
MessageModal>GoToMeeting
Goto>Test1
//GoSub>SetGoToMeeting
// Load the supplied URL (might have to do multiple times for GoToMyPC)
VBRun>CreateIE
VBRun>Navigate,%url%
VBRun>WaitBusy
// Need some sort of error checking e.g. what if internet connection is down?
// Could get file not found, server error, etc?
// In session?
//Remove Shutdown Option
//Let>strvalue=""
//RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoClose,strValue
//MessageModal>strValue
Label>Test1
Label>End
Exit>1
// End of main part of macro
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// Subroutines below
//---------------------------------------------------------------------
// GoToMyPC_Connect - link to remote PC
SRT>GoToMyPC_Connect
Label>GTMPC_Start
// Window Title
Let>g2ctitle={"GoToMyPC Corporate :"+" "}
// Don't always get gotomypc page to redirect at first
Let>k=5
Repeat>k
// Load the supplied URL
VBRun>CreateIE
VBRun>Navigate,%connUrl%
VBRun>WaitBusy
// Wait for GoToMyPC
Let>WW_TIMEOUT=60
WaitWindowOpen>{%g2ctitle%+"Download*"}
If>WW_RESULT=FALSE
Let>k=k-1
// Close the IE Window
VBRun>KillIE
// Wait 1 min, 2 min, ... 5 min and try again
Let>waitsecs={(5-%k%)*60}
Message>Waiting %waitsecs% seconds to try GoToMyPC
Let>WW_TIMEOUT=%waitsecs%
GoSub>MSMsgClose
Else
Let>k=0
Endif
Until>k=0
// Did we get it?
IfWindowOpen>{%g2ctitle%+"Download*"}
// Make sure we're working in the correct window
SetFocus>{%g2ctitle%+"Download*"}
Else
Message>Cannot connect to GoToMyPC: %g2pcName%
Let>WW_TIMEOUT=7200
GoSub>MSMsgClose
Goto>G2PCC_End
Endif
// Click the Download button
Let>g2URL=www.gotomypc.com
// First find IE window
VBEval>GetIE("%g2URL%"),foundIt
If>foundIt=True
//Click the button
VBEval>ClickIt("Download"),foundIt
// No download button?
If>foundIt=False
Message>Could not find download button!
Let>WW_TIMEOUT=10
GoSub>MSMsgClose
// Close the IE Window
VBRun>KillIE
// Try again
GoTo>GTMPC_Start
Endif
// We pressed the button, give it a little time to catch up
Wait>2
Else
// Couldn't find an IE window with matching URL
Message>Could not find %g2URL% IE instance!
Let>WW_TIMEOUT=10
GoSub>MSMsgClose
GoTo>GTMPC_Start
Endif
// Sometimes we get session completed here - try again
IfWindowOpen>{%g2ctitle%+"Session Completed*"}
CloseWindow>{%g2ctitle%+"Session Completed*"}
GoTo>GTMPC_Start
Endif
// If the IE Download Security Bar shows up deal with it
Let>NumFound=0
// Is it IE 6 or 7
If>IEVerMaj=7
// FindImagePos>iedwldsec7.bmp,SCREEN,0,1,Xfip,Yfip,NumFound
Endif
If>IEVerMaj=6
// FindImagePos>iedwldsec6.bmp,SCREEN,0,1,Xfip,Yfip,NumFound
Endif
If>NumFound>0
Let>x=%Xfip_0%
Let>y=%Yfip_0%
MouseMove>x,y
Lclick
// Should have popup menu now click Download File...
Wait>1
Let>x=x+10
Let>y=y+10
MouseMove>x,y
Lclick
// Say we did it
Let>foundIt=TRUE
Endif
// Should have File Download
Let>wtitle=File Download*
Let>WW_TIMEOUT=15
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Run the file (Alt-R)
Wait>1
Press ALT
Send Character/Text>R
Release ALT
Let>wtitle=Internet Explorer - Security Warning*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Run the file
Wait>1
Press ALT
Send Character/Text>R
Release ALT
Endif
Else
// Could try to click the link?
// Go somewhere to try again?
CloseWindow>{%g2ctitle%+"Download*"}
GoTo>GTMPC_Start
Endif
// Might get "Unexpected Error" Window
// Enter Access Code
Let>foundIt=FALSE
Let>wtitle=Enter Access Code*
Let>WW_TIMEOUT=120
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
Wait>1
Let>SK_DELAY=1
Send Character/Text>1234abcd
PushButton>%wtitle%,OK
Let>foundIt=TRUE
Endif
// Close IE
IfWindowOpen>{%g2ctitle%+"Download*"}
CloseWindow>{%g2ctitle%+"Download*"}
Endif
// If the Access Code didn't work there's a problem
If>foundIt=FALSE
GoTo>GTMPC_Start
Endif
// GoToMyPC should be open now
Label>G2PCC_End
END>GoToMyPC_Connect
//---------------------------------------------------------------------
// GoToPC_Shortcut - Drop a GoToMyPC shortcut on the desktop
SRT>GoToPC_Shortcut
// If the window isn't open don't bother
IfWindowOpen>%g2pcName%*,,G2PC_End
SetFocus>%g2pcName%*
// Open File Menu
MouseMoveRel>50,15
Lclick
// Pick Create Shortcut
MouseMoveRel>70,40
Lclick
// Wait for Shortcut Window
Let>wtitle=Create Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Say yes we want a shortcut
PushButton>%wtitle%,&Yes
// Look for password window
Let>wtitle=Desktop Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Enter the password
Let>SK_DELAY=1
Send Character/Text>300Delaware
PushButton>%wtitle%,Continue
// Look for confirmation window
Let>wtitle=Desktop Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Confirm
PushButton>%wtitle%,OK
Endif
Endif
Endif
Label>G2PC_End
END>GoToPC_Shortcut
//---------------------------------------------------------------------
// GoToPC_Maximize - Maximize GoToPC Window
SRT>GoToPC_Maximize
// Maximize Window
SetFocus>%g2pcName%*
// Open View Menu
MouseMoveRel>90,15
Lclick
// Pick Full Screen
MouseMoveRel>110,70
Lclick
END>GoToPC_Maximize
//---------------------------------------------------------------------
// SetGoToMeeting - once GoToMeeting window is up set our preferences
SRT>SetGoToMeeting
IfWindowOpen>GrabTab,,SGTM_End
// Where is it?
GetWindowPos>GrabTab,nXPos,nYPos
SetFocus>GrabTab
// Full Screen
MouseMove>%nXpos%+13,%nYpos%+40
LClick
// Close Control Panel
MouseMove>%nXpos%+13,%nYpos%+20
LClick
Label>SGTM_End
END>SetGoToMeeting
//---------------------------------------------------------------------
// TurnOffScreenSaver - make sure screen saver is off
SRT>TurnOffScreenSaver
//Might need to have XP/Vista option?
Let>wtitle=Display Properties
// Open the dialog box
ExecuteFile>desk.cpl
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=FALSE,TOSS_End
SetFocus>%wtitle%
// Select Screen Saver Tab
Press CTRL
Press Tab * 2
Release CTRL
// Set screen saver to nothing
Press ALT
Send Character/Text>S
Release ALT
Press Home
Press Tab
// Set it!
PushButton>%wtitle%,OK
Label>TOSS_End
END>TurnOffScreenSaver
//---------------------------------------------------------------------
// SetPowerOptions -
// Manage Power Option Settings through Power Options Properties Dialog
SRT>SetPowerOptions
//Might need to have XP/Vista option?
Let>wtitle=Power Options Properties
// Open the dialog box
ExecuteFile>powercfg.cpl
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=FALSE,SPO_End
SetFocus>%wtitle%
// Assuming that Power Schemes tab is selected by default
// Set monitor turnoff to 3 hours
Press ALT
Send Character/Text>M
Release ALT
Press Home
Press Down * 12
Press Tab
// Set Standby to Never
Press ALT
Send Character/Text>T
Release ALT
Press End
Press Tab
// Set Hibernate to Never
Press ALT
Send Character/Text>H
Release ALT
Press End
Press Tab
// Select Advanced Tab
Press CTRL
Press Tab
Release CTRL
// Set Power Button to Do Nothing
Press ALT
Send Character/Text>E
Release ALT
Press Home
Press Tab
// Set Sleep Button to Do Nothing
Press ALT
Send Character/Text>N
Release ALT
Press Home
Press Tab
// Set it!
PushButton>%wtitle%,OK
Label>SPO_End
END>SetPowerOptions
//---------------------------------------------------------------------
// Connectivity - make sure we can get to the internet
SRT>Connectivity
//---------------------------------------------------------------------
// If no internet then we have a problem
// pingOk = Y if can be pinged, N if not
// Use google as a surrogate for having internet
Let>pingurl=www.google.com
// CheckURL tries 5 times over about 10 minutes
GoSub>CheckURL
// If it didn't work then no sense going forward
If>pingOk=N
MessageModal>Error: No internet connectivity!
Goto>Connectivity_End
Endif
//---------------------------------------------------------------------
// Make sure ONLC.COM is available
Let>pingurl=www.onlc.com
GoSub>CheckURL
// If it didn't work then no sense going forward
If>pingOk=N
MessageModal>Error: ONLC.COM is not responding!%CRLF%%CRLF%Call 800-288-8221
Endif
Label>Connectivity_End
End>Connectivity
//---------------------------------------------------------------------
// CheckURL - try pinging multiple times
// Set pingurl to test point
SRT>CheckURL
// Assume it didn't work
Let>urlOk=N
// have to have pingurl or desturl
MessageModal>About to check assigned
Assigned>pingurl,havePing
Assigned>desturl,haveDest
MessageModal>After assigned
If>havePing=FALSE AND haveDest=FALSE
Goto>CheckURL_End
Endif
// Try to ping/connect - give up after k! minutes, if k=5 then 11 minutes
Let>k=5
Repeat>k
Let>k=k-1
// Is URL there?
If>havePing=TRUE
GoSub>Ping
Let>urlOk=pingOk
Endif
If>haveDest=TRUE
//Request the URL via GET
HTTPRequest>%desturl%,,GET,,urlResponse
//If result isn't XML then assume error: 4xx, 5xx
Position>nPos=1
Let>urlOk=Y
Endif
Endif
If>urlOk=Y
Let>k=0
Else
// Wait 1 min, 2 min, ... 5 min and try again
Let>waitsecs={(5-%k%)*60}
If>havePing=TRUE
Message>Can't ping: %pingurl% %CRLF%%CRLF% Trying again in %waitsecs% seconds
Endif
If>haveDest=TRUE
Message>%desturl% %CRLF%%CRLF% results in: %CRLF% %urlResponse% %CRLF%%CRLF% Trying again in %waitsecs% seconds
Endif
Wait>%waitsecs%
// Close the messagebox
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
Endif
Until>k=0
Label>CheckURL_End
END>CheckURL
//---------------------------------------------------------------------
// Ping - see if we can see out
// Set pingurl to test point
SRT>Ping
// have to have pingurl
Assigned>pingurl,havePurl
If>havePurl=FALSE
Goto>Ping_End
Endif
// Assume it doesn't work
Let>pingOk=N
// Wait for run to terminate before continuing
Let>RP_WAIT=1
Let>filen=%TEMP_DIR%pingtest
Run>cmd /c ping %pingurl% >%filen%
ReadFile>%filen%,filetxt
DeleteFile>%filen%
Separate>filetxt,Reply from,var
If>var_count>2
Let>pingOk=Y
Endif
Label>Ping_End
END>Ping
//---------------------------------------------------------------------
// MSMsgClose - put up message for a while and then move on
// time set with WW_TIMEOUT
SRT>MSMsgClose
WaitWindowClosed>Macro Scheduler Message
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
END>MSMsgClose
//---------------------------------------------------------------------
// ShowTabSel - show which Tab is selected
SRT>ShowTabSel
// Which tab is selected?
Let>TCM_GETCURSEL=4875
//Get the handle of the Display Properties Window
GetWindowHandle>Power Options*,hwnd
//Find the handle of the SysTabControl32 (Tab Control) object
LibFunc>User32,FindWindowExA,tabctrl,hwnd,0,SysTabControl32,
//Send the TCM_GETCURSEL message to retrieve the selected tab index
LibFunc>user32,SendMessageA,tabindex,tabctrl,TCM_GETCURSEL,0,0
//Display the result
MessageModal>Selected Tab: %tabindex%
END>ShowTabSel
I'm running into this same Access Violation issue with EXE's in 10.1.17. The Assigned> statement is causing the Access Violation message when executing the EXE but doesn't happen when its not an EXE.
I haven't been able to figure out exactly what triggers the problem though. The script that has the issue is 800 lines long and is doing a lot of stuff. When I make shorter scripts to try to narrow it down the Assigned> statement seems to work ok in the EXE. Maybe the problem is related to the length of the script?
The script which is causing the problem is listed below. When this script is compiled and the Access Violation occurs right away and every time at line 670. When run a message is popped just before the Assigned> statement is executed.
Hope this helps in some way.
Warm regards,
Jim Palic
//Initialise VBScript
VBSTART
Function DeXml (strXML)
Dim regEx, Matches
Set regEx = New RegExp
regEx.Pattern = "]*>(.*)"
Set Matches = regEx.Execute(strXML)
If Matches.Count > 0 Then
DeXML = Matches(0).Submatches(0)
Else
DeXML = strXML
End If
Set Matches = Nothing
Set regEx = Nothing
End Function
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
'Navigates IE to specified URL
Sub Navigate(URL)
IE.Navigate URL
WaitBusy
End Sub
Sub WaitBusy
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = Nothing
End Sub
'Attaches to an existing instance of IE with matching URL
Function GetIE(giURL)
Dim objInstances, objIE
GetIE = False
Set objInstances = CreateObject("Shell.Application").windows
If objInstances.Count > 0 Then '/// make sure we have instances open.
For Each objIE In objInstances
If InStr(objIE.LocationURL,giURL) > 0 then
Set IE = objIE
GetIE = True
Exit For
End If
Next
End If
Set objIE = Nothing
Set objInstances = Nothing
End Function
'clicks specified link
Function ClickIt(elemText)
Dim elems
Dim ItemNr
ClickIt = False
Set elems = IE.document.getElementsbyTagname("input")
For ItemNr = 0 to elems.length - 1
'MsgBox elems.Item(ItemNr).value
If elems.Item(ItemNr).value = elemText Then
elems.Item(ItemNr).click
ClickIt = True
End If
Next
Set elems = Nothing
WaitBusy
End Function
'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
dim t
set t = IE.document.getElementsbyTagname(Tagname)
if all=1 then
ExtractTag = t.Item(Num).outerHTML
else
ExtractTag = t.Item(Num).innerText
end if
End Function
' DeleteG2ShortCut - get rid of leftover shortcuts
Sub DeleteG2Shortcut
Dim strDesktop
' Which folder has the desktop?
Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set WshShell = Nothing
' Get a list of files in the desktop
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oDir = objFSO.GetFolder(strDesktop)
Set oFiles = oDir.Files
' Look at each file
For Each f In oFiles
sExt = UCase(objFSO.GetExtensionName(f.Name))
' Is it a link?
If sExt = "LNK" Then
' Is it a GoToMyPC shortcut?
If Left(f.Name, 11) = "GoToMyPC - " Then
objFSO.DeleteFile(strDesktop & "\" & f.Name)
End If
End If
Next
Set f = Nothing
Set oFiles = Nothing
Set oDir = Nothing
Set objFSO = Nothing
End Sub
VBEND
//---------------------------------------------------------------------
// Program Starts Here
// Messageboxes are on top of all windows
Let>MSG_STAYONTOP=1
//Get computer name
Let>compName=FLORCARTI
//Input>compName,Computer Name:
//---------------------------------------------------------------------
// Run connectivity tests to make sure we can get to ONLC.COM
Gosub>Connectivity
If>pingOK=N,End
//---------------------------------------------------------------------
//Ask webservice for url of GoToMyPC/GoToMeeting connection (based on computer name)
Let>desturl=http://www.onlc.com/webservices/cnifrna ... =%compName%
Gosub>CheckURL
If>urlOK=N,End
//---------------------------------------------------------------------
// Get text of response
// Clean response so we can pass to VB
StringReplace>urlResponse,",,strResp
StringReplace>strResp,CRLF,,strResp
// Strip XML stuff Off
VBEval>DeXml("%strResp%"),connUrl
//---------------------------------------------------------------------
// If return results in ERR show it and stop
MidStr>connUrl,1,3,strSub
If>strSub=ERR
MessageModal>%connUrl%
Goto>End
Endif
//---------------------------------------------------------------------
// If return results in MSG show it for a bit and then stop
MidStr>connUrl,1,3,strSub
If>strSub=MSG
Message>%connUrl%
Let>WW_TIMEOUT=60
WaitWindowClosed>Macro Scheduler Message
// Close the messagebox
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
Goto>End
Endif
Label>Cont1
Let>connUrl=http://www.onlc.com
// Need to know IE Version (full version is IEVerStr, major (6,7,etc) is IEVerMaj
Let>IEVerMaj=7
//RegistryReadKey>HKEY_LOCAL_MACHINE,Software\Microsoft\Internet Explorer,Version,IEVerStr
//MidStr>%IEVerStr%,1,1,IEVerMaj
//---------------------------------------------------------------------
// Need to know whether we're doing GoToMeeting or GoToMyPC
Let>g2pcName={""}
Position>gotomypc,connUrl,1,nPos
If>nPos>0
// Deduce GoToMyPC window name
Length>connUrl,nLen
Position>pc=,connUrl,1,nPos
MidStr>connUrl,{%nPos%+3},{%nLen%-%nPos%-2},g2pcName
StringReplace>g2pcName,%20,{" "},g2pcName
Endif
If>{Length(%g2pcName%)=0},GoToMeeting
//---------------------------------------------------------------------
// GoToMyPC Startup
Label>GoToMyPC
// Try to close other leftover windows
//GetWindowList>winList
//Separate>winlist,CRLF,windows
//Let>k=1
//Repeat>k
//Let>this=windows_%k%
//MessageModal>this
//Let>k=k+1
//Until>k>windows_count
// If the window is already open then assume we're good to go
IfWindowOpen>%g2pcName%*
Message>GoToMyPC %g2pcName% already open
Let>WW_TIMEOUT=15
GoSub>MSMsgClose
Goto>End
Endif
// Perform connect steps
GoSub>GoToMyPC_Connect
// Make sure it's open
Let>WW_TIMEOUT=20
WaitWindowOpen>%g2pcName%*
// If we're connected
If>WW_RESULT=TRUE
// Give the window a little time to settle down
Wait>5
// Delete old shortcuts
VBRun>DeleteG2Shortcut
// Make a new shortcut
Gosub>GoToPC_Shortcut
// Maximize the window
Gosub>GoToPC_Maximize
Else
// Some unexpected error occurred
Message>GoToMyPC %g2pcName% did not open!
Let>WW_TIMEOUT=60
GoSub>MSMsgClose
// Try again
Goto>GoToMyPC
Endif
// Done with GoToMyPC
Goto>End
//---------------------------------------------------------------------
// GoToMeeting Startup
Label>GoToMeeting
MessageModal>GoToMeeting
Goto>Test1
//GoSub>SetGoToMeeting
// Load the supplied URL (might have to do multiple times for GoToMyPC)
VBRun>CreateIE
VBRun>Navigate,%url%
VBRun>WaitBusy
// Need some sort of error checking e.g. what if internet connection is down?
// Could get file not found, server error, etc?
// In session?
//Remove Shutdown Option
//Let>strvalue=""
//RegistryReadKey>HKEY_CURRENT_USER,Software\Microsoft\Windows\CurrentVersion\Policies\Explorer,NoClose,strValue
//MessageModal>strValue
Label>Test1
Label>End
Exit>1
// End of main part of macro
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// Subroutines below
//---------------------------------------------------------------------
// GoToMyPC_Connect - link to remote PC
SRT>GoToMyPC_Connect
Label>GTMPC_Start
// Window Title
Let>g2ctitle={"GoToMyPC Corporate :"+" "}
// Don't always get gotomypc page to redirect at first
Let>k=5
Repeat>k
// Load the supplied URL
VBRun>CreateIE
VBRun>Navigate,%connUrl%
VBRun>WaitBusy
// Wait for GoToMyPC
Let>WW_TIMEOUT=60
WaitWindowOpen>{%g2ctitle%+"Download*"}
If>WW_RESULT=FALSE
Let>k=k-1
// Close the IE Window
VBRun>KillIE
// Wait 1 min, 2 min, ... 5 min and try again
Let>waitsecs={(5-%k%)*60}
Message>Waiting %waitsecs% seconds to try GoToMyPC
Let>WW_TIMEOUT=%waitsecs%
GoSub>MSMsgClose
Else
Let>k=0
Endif
Until>k=0
// Did we get it?
IfWindowOpen>{%g2ctitle%+"Download*"}
// Make sure we're working in the correct window
SetFocus>{%g2ctitle%+"Download*"}
Else
Message>Cannot connect to GoToMyPC: %g2pcName%
Let>WW_TIMEOUT=7200
GoSub>MSMsgClose
Goto>G2PCC_End
Endif
// Click the Download button
Let>g2URL=www.gotomypc.com
// First find IE window
VBEval>GetIE("%g2URL%"),foundIt
If>foundIt=True
//Click the button
VBEval>ClickIt("Download"),foundIt
// No download button?
If>foundIt=False
Message>Could not find download button!
Let>WW_TIMEOUT=10
GoSub>MSMsgClose
// Close the IE Window
VBRun>KillIE
// Try again
GoTo>GTMPC_Start
Endif
// We pressed the button, give it a little time to catch up
Wait>2
Else
// Couldn't find an IE window with matching URL
Message>Could not find %g2URL% IE instance!
Let>WW_TIMEOUT=10
GoSub>MSMsgClose
GoTo>GTMPC_Start
Endif
// Sometimes we get session completed here - try again
IfWindowOpen>{%g2ctitle%+"Session Completed*"}
CloseWindow>{%g2ctitle%+"Session Completed*"}
GoTo>GTMPC_Start
Endif
// If the IE Download Security Bar shows up deal with it
Let>NumFound=0
// Is it IE 6 or 7
If>IEVerMaj=7
// FindImagePos>iedwldsec7.bmp,SCREEN,0,1,Xfip,Yfip,NumFound
Endif
If>IEVerMaj=6
// FindImagePos>iedwldsec6.bmp,SCREEN,0,1,Xfip,Yfip,NumFound
Endif
If>NumFound>0
Let>x=%Xfip_0%
Let>y=%Yfip_0%
MouseMove>x,y
Lclick
// Should have popup menu now click Download File...
Wait>1
Let>x=x+10
Let>y=y+10
MouseMove>x,y
Lclick
// Say we did it
Let>foundIt=TRUE
Endif
// Should have File Download
Let>wtitle=File Download*
Let>WW_TIMEOUT=15
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Run the file (Alt-R)
Wait>1
Press ALT
Send Character/Text>R
Release ALT
Let>wtitle=Internet Explorer - Security Warning*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Run the file
Wait>1
Press ALT
Send Character/Text>R
Release ALT
Endif
Else
// Could try to click the link?
// Go somewhere to try again?
CloseWindow>{%g2ctitle%+"Download*"}
GoTo>GTMPC_Start
Endif
// Might get "Unexpected Error" Window
// Enter Access Code
Let>foundIt=FALSE
Let>wtitle=Enter Access Code*
Let>WW_TIMEOUT=120
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
Wait>1
Let>SK_DELAY=1
Send Character/Text>1234abcd
PushButton>%wtitle%,OK
Let>foundIt=TRUE
Endif
// Close IE
IfWindowOpen>{%g2ctitle%+"Download*"}
CloseWindow>{%g2ctitle%+"Download*"}
Endif
// If the Access Code didn't work there's a problem
If>foundIt=FALSE
GoTo>GTMPC_Start
Endif
// GoToMyPC should be open now
Label>G2PCC_End
END>GoToMyPC_Connect
//---------------------------------------------------------------------
// GoToPC_Shortcut - Drop a GoToMyPC shortcut on the desktop
SRT>GoToPC_Shortcut
// If the window isn't open don't bother
IfWindowOpen>%g2pcName%*,,G2PC_End
SetFocus>%g2pcName%*
// Open File Menu
MouseMoveRel>50,15
Lclick
// Pick Create Shortcut
MouseMoveRel>70,40
Lclick
// Wait for Shortcut Window
Let>wtitle=Create Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Say yes we want a shortcut
PushButton>%wtitle%,&Yes
// Look for password window
Let>wtitle=Desktop Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Enter the password
Let>SK_DELAY=1
Send Character/Text>300Delaware
PushButton>%wtitle%,Continue
// Look for confirmation window
Let>wtitle=Desktop Shortcut*
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=TRUE
// Confirm
PushButton>%wtitle%,OK
Endif
Endif
Endif
Label>G2PC_End
END>GoToPC_Shortcut
//---------------------------------------------------------------------
// GoToPC_Maximize - Maximize GoToPC Window
SRT>GoToPC_Maximize
// Maximize Window
SetFocus>%g2pcName%*
// Open View Menu
MouseMoveRel>90,15
Lclick
// Pick Full Screen
MouseMoveRel>110,70
Lclick
END>GoToPC_Maximize
//---------------------------------------------------------------------
// SetGoToMeeting - once GoToMeeting window is up set our preferences
SRT>SetGoToMeeting
IfWindowOpen>GrabTab,,SGTM_End
// Where is it?
GetWindowPos>GrabTab,nXPos,nYPos
SetFocus>GrabTab
// Full Screen
MouseMove>%nXpos%+13,%nYpos%+40
LClick
// Close Control Panel
MouseMove>%nXpos%+13,%nYpos%+20
LClick
Label>SGTM_End
END>SetGoToMeeting
//---------------------------------------------------------------------
// TurnOffScreenSaver - make sure screen saver is off
SRT>TurnOffScreenSaver
//Might need to have XP/Vista option?
Let>wtitle=Display Properties
// Open the dialog box
ExecuteFile>desk.cpl
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=FALSE,TOSS_End
SetFocus>%wtitle%
// Select Screen Saver Tab
Press CTRL
Press Tab * 2
Release CTRL
// Set screen saver to nothing
Press ALT
Send Character/Text>S
Release ALT
Press Home
Press Tab
// Set it!
PushButton>%wtitle%,OK
Label>TOSS_End
END>TurnOffScreenSaver
//---------------------------------------------------------------------
// SetPowerOptions -
// Manage Power Option Settings through Power Options Properties Dialog
SRT>SetPowerOptions
//Might need to have XP/Vista option?
Let>wtitle=Power Options Properties
// Open the dialog box
ExecuteFile>powercfg.cpl
Let>WW_TIMEOUT=5
WaitWindowOpen>%wtitle%
If>WW_RESULT=FALSE,SPO_End
SetFocus>%wtitle%
// Assuming that Power Schemes tab is selected by default
// Set monitor turnoff to 3 hours
Press ALT
Send Character/Text>M
Release ALT
Press Home
Press Down * 12
Press Tab
// Set Standby to Never
Press ALT
Send Character/Text>T
Release ALT
Press End
Press Tab
// Set Hibernate to Never
Press ALT
Send Character/Text>H
Release ALT
Press End
Press Tab
// Select Advanced Tab
Press CTRL
Press Tab
Release CTRL
// Set Power Button to Do Nothing
Press ALT
Send Character/Text>E
Release ALT
Press Home
Press Tab
// Set Sleep Button to Do Nothing
Press ALT
Send Character/Text>N
Release ALT
Press Home
Press Tab
// Set it!
PushButton>%wtitle%,OK
Label>SPO_End
END>SetPowerOptions
//---------------------------------------------------------------------
// Connectivity - make sure we can get to the internet
SRT>Connectivity
//---------------------------------------------------------------------
// If no internet then we have a problem
// pingOk = Y if can be pinged, N if not
// Use google as a surrogate for having internet
Let>pingurl=www.google.com
// CheckURL tries 5 times over about 10 minutes
GoSub>CheckURL
// If it didn't work then no sense going forward
If>pingOk=N
MessageModal>Error: No internet connectivity!
Goto>Connectivity_End
Endif
//---------------------------------------------------------------------
// Make sure ONLC.COM is available
Let>pingurl=www.onlc.com
GoSub>CheckURL
// If it didn't work then no sense going forward
If>pingOk=N
MessageModal>Error: ONLC.COM is not responding!%CRLF%%CRLF%Call 800-288-8221
Endif
Label>Connectivity_End
End>Connectivity
//---------------------------------------------------------------------
// CheckURL - try pinging multiple times
// Set pingurl to test point
SRT>CheckURL
// Assume it didn't work
Let>urlOk=N
// have to have pingurl or desturl
MessageModal>About to check assigned
Assigned>pingurl,havePing
Assigned>desturl,haveDest
MessageModal>After assigned
If>havePing=FALSE AND haveDest=FALSE
Goto>CheckURL_End
Endif
// Try to ping/connect - give up after k! minutes, if k=5 then 11 minutes
Let>k=5
Repeat>k
Let>k=k-1
// Is URL there?
If>havePing=TRUE
GoSub>Ping
Let>urlOk=pingOk
Endif
If>haveDest=TRUE
//Request the URL via GET
HTTPRequest>%desturl%,,GET,,urlResponse
//If result isn't XML then assume error: 4xx, 5xx
Position>nPos=1
Let>urlOk=Y
Endif
Endif
If>urlOk=Y
Let>k=0
Else
// Wait 1 min, 2 min, ... 5 min and try again
Let>waitsecs={(5-%k%)*60}
If>havePing=TRUE
Message>Can't ping: %pingurl% %CRLF%%CRLF% Trying again in %waitsecs% seconds
Endif
If>haveDest=TRUE
Message>%desturl% %CRLF%%CRLF% results in: %CRLF% %urlResponse% %CRLF%%CRLF% Trying again in %waitsecs% seconds
Endif
Wait>%waitsecs%
// Close the messagebox
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
Endif
Until>k=0
Label>CheckURL_End
END>CheckURL
//---------------------------------------------------------------------
// Ping - see if we can see out
// Set pingurl to test point
SRT>Ping
// have to have pingurl
Assigned>pingurl,havePurl
If>havePurl=FALSE
Goto>Ping_End
Endif
// Assume it doesn't work
Let>pingOk=N
// Wait for run to terminate before continuing
Let>RP_WAIT=1
Let>filen=%TEMP_DIR%pingtest
Run>cmd /c ping %pingurl% >%filen%
ReadFile>%filen%,filetxt
DeleteFile>%filen%
Separate>filetxt,Reply from,var
If>var_count>2
Let>pingOk=Y
Endif
Label>Ping_End
END>Ping
//---------------------------------------------------------------------
// MSMsgClose - put up message for a while and then move on
// time set with WW_TIMEOUT
SRT>MSMsgClose
WaitWindowClosed>Macro Scheduler Message
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
Endif
END>MSMsgClose
//---------------------------------------------------------------------
// ShowTabSel - show which Tab is selected
SRT>ShowTabSel
// Which tab is selected?
Let>TCM_GETCURSEL=4875
//Get the handle of the Display Properties Window
GetWindowHandle>Power Options*,hwnd
//Find the handle of the SysTabControl32 (Tab Control) object
LibFunc>User32,FindWindowExA,tabctrl,hwnd,0,SysTabControl32,
//Send the TCM_GETCURSEL message to retrieve the selected tab index
LibFunc>user32,SendMessageA,tabindex,tabctrl,TCM_GETCURSEL,0,0
//Display the result
MessageModal>Selected Tab: %tabindex%
END>ShowTabSel
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I have PMd you regarding a debug version of the compiler so that we can get more error information and get this sorted.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Assigned> Still the Culprit I think
Marcus,
I PM'd you a note with another example of an access violation on a compiled script. This time it didn't occur immediately on the Assigned> statement. But if I get rid of the Assigned> statement the Access Violation goes away.
Jim Palic
I PM'd you a note with another example of an access violation on a compiled script. This time it didn't occur immediately on the Assigned> statement. But if I get rid of the Assigned> statement the Access Violation goes away.
Jim Palic