It was a bad idea from the start, but even as bad ideas go, this one went horribly wrong.

A 38-year-old Avon Lake, Ohio, man is set to plead guilty to federal charges after spyware he allegedly meant to install on the computer of a woman he'd had a relationship with ended up infecting computers at Akron Children's Hospital.

In late February 2008, Scott Graham shelled out US$115 for a spyware program called SpyAgent and sent it to the woman, according to a plea agreement filed in the U.S. District Court for the Northeastern District of Ohio.

He allegedly sent the spyware to the woman's Yahoo e-mail address, hoping that it would give him a way to monitor what she was doing on her PC. But instead, she opened the spyware on a computer in the hospital's pediatric cardiac surgery department, creating a regulatory nightmare for the hospital.

The complaint does not explain how Graham managed to convince the woman to install the program, but clever attackers often trick their victims into clicking on files by saying that they are interesting videos or some kind of useful software.

Between March 19 and March 28 the spyware sent more than 1,000 screen captures to Graham via e-mail. They included details of medical procedures, diagnostic notes and other confidential information relating to 62 hospital patients. He was also able to obtain e-mail and financial records of four other hospital employees as well, the plea agreement states.

Graham, who is set to formally enter a guilty plea on Sept. 30 to one count of illegally intercepting electronic communications, will pay $33,000 to the hospital for damages caused by the incident. He faces a maximum sentence of five years in prison.

"While Scott Graham does take responsibility for his conduct, it was never his intention to harm any organization or entity," said his attorney, Ian Friedman, in a telephone interview. "He had to learn the hard way that what may be advertised on the Internet doesn't necessary produce what's promised."

Products such as SpyAgent are marketed as legitimate tools to help employers or worried parents keep track of what's going on with their computers, but they can easily be misused to spy on innocent victims, said Eric Howes, director of research services with antivirus company Sunbelt Software.

His company flags SpyAgent as a "commercial keylogger."

"Our enterprise customers are concerned about these kinds of tools being used in an unauthorized fashion on their networks," Howes said. "They have completely legitimate uses, but if I went home and found a copy of [this type of software] on my computer, I would be concerned. "

Still Howes faulted the hospital's IT staff for allowing someone to download spyware from Yahoo mail and install it on their systems. "That points to a security failing at that hospital, but then they aren't that different from 99 percent of companies out there," he said.

Many companies block workers from accessing personal Web sites such as Yahoo or Facebook.

The U.S. attorney prosecuting this case, Robert Kern, did not return messages seeking comment. A spokeswoman with the Akron Children's Hospital was unaware of the case and unable to comment.