Jump to content
Sign in to follow this  
Malcolm

Strange Hard Disk consuming Java process

Recommended Posts

Malcolm

I have a script which I think is somehow occasionally spawning an out of control Java process whereby Java.exe begins accessing the Hard Disk at near full capacity without stopping.

It's a very simple script, modified from a script posted by Friedrich Huebler, for sending code to the STATA statistical program via a temporary save file and a copy and paste function. My only change (or so I believe) was to have the program re-activate the original window (in this case Notepad++) instead of staying in the STATA window after the paste.

What is happening is that occasionally, and I can't really pinpoint what I do that causes it, an unkillable Java.exe process starts up which begins spinning accessing the hard disk at full capacity without stopping. When I inspect Java.exe it tells me that it's parent is rundolines.exe (the file I created). It only happens occasionally, but you can't miss it when it does happen because the hard disk spins up like mad and won't stop. Does anyone have any ideas why? I am completely stumped.

I'm running Windows XP (I don't have administrator rights by the way.) Java is up to date and only the most recent version has been retained. Additionally, Symmatec Anti-Virus is up to date and running error free.

; AutoIt v3 script to run Stata commands from an external text editor
; Version 3, Friedrich Huebler, fhuebler@gmail.com, www.huebler.info, 27 April 2008

; Declare variables
Global $ini, $statapath, $statawin, $winpause, $keypause, $clippause, $commands, $tempfile, $tempfile2

; File locations
; Path to INI file
$ini = @ScriptDir & "\rundolines.ini"
; Path to Stata executable
$statapath = IniRead($ini, "Stata", "statapath", "C:\Program Files\Stata9\wstata.exe")
; Title of Stata window
$statawin = IniRead($ini, "Stata", "statawin", "Intercooled Stata 9.2")
$comeback = IniRead($ini, "activewin", "comeback",1)
;Get title of notepad to return to
$notewin = WinGetTitle("")


; Delays
; Pause after copying of Stata commands to clipboard
$clippause = IniRead($ini, "Delays", "clippause", "100")
; Pause between window-related operations
$winpause = IniRead($ini, "Delays", "winpause", "200")
; Pause between keystrokes sent to Stata
$keypause = IniRead($ini, "Delays", "keypause", "1")

; Set SendKeyDelay and WinWaitDelay to speed up or slow down script
Opt("WinWaitDelay", $winpause)
Opt("SendKeyDelay", $keypause)

; If more than one Stata window is open, the window 
; that was most recently active will be matched
Opt("WinTitleMatchMode", 2)

; Clear clipboard
ClipPut("")
; Copy selected lines from editor to clipboard
Send("^c")
; Pause avoids problem with clipboard, may be AutoIt or Windows bug
Sleep($clippause)
$commands = ClipGet()

; Terminate script if no commands selected in editor
If $commands = "" Then 
  Exit
EndIf

; Create file name in system temporary directory
$tempfile = EnvGet("TEMP") & "\statacmd.tmp"

; Open file for writing and check that it worked
$tempfile2 = FileOpen($tempfile, 2)
If $tempfile2 = -1 Then
  MsgBox(0, "Error: Cannot open temporary file", "at [" & $tempfile & "]")
  Exit
EndIf

; Write commands to temporary file, add CR-LF at end
; to ensure last line is executed by Stata
FileWrite($tempfile2, $commands & @CRLF)
FileClose($tempfile2)

; Check if Stata is already open, start Stata if not
If WinExists($statawin) Then
  WinActivate($statawin)
  WinWaitActive($statawin)
 ; Activate Stata Command Window and select text (if any)
  Send("^4")
  Send("^a")
 ; Run temporary file
 ; Double quotes around $tempfile needed in case path contains blanks
  ClipPut("do " & '"' & $tempfile & '"')
 ; Pause avoids problem with clipboard, may be AutoIt or Windows bug
  Sleep($clippause)
  Send("^v" & "{Enter}")
Else
  Run($statapath)
  WinWaitActive($statawin)
 ; Activate Stata Command Window
  Send("^4")
 ; Run temporary file
 ; Double quotes around $dofile needed in case path contains blanks
  ClipPut("do " & '"' & $tempfile & '"')
 ; Pause avoids problem with clipboard, may be AutoIt or Windows bug
  Sleep($clippause)
  Send("^v" & "{Enter}")
EndIf

If $comeback = 1 Then WinActivate($notewin)
If $comeback = 1 Then Send("{RIGHT}")
; End of script

Here's the .ini file it's referring to:

; AutoIt v3 INI file to run Stata commands from an external text editor
; Version 3, Friedrich Huebler, fhuebler@gmail.com, www.huebler.info, 27 April 2008

[Stata]
; Path to Stata executable
statapath = "C:\Program Files\Stata9\wstata.exe"

; Title of Stata Window
statawin = "Intercooled Stata 9.2"


[Delays]
; Pause after copying of Stata commands to clipboard, in milliseconds
; Use higher number if script fails (default: 100, recommended range: 0 - 200)
clippause = 100

; Pause between window-related operations, in milliseconds
; Use lower number to speed up script, higher number if script fails (default: 200)
winpause = 200

; Pause between key strokes sent to Stata, in milliseconds
; Use lower number to speed up script, higher number if script fails (default: 1)
keypause = 1

[activewin]
comeback = 1

; End of INI file

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×