The other tempting target for hackers, the statewide voter registration database, also is tightly guarded. In 2016, Russian hackers broke into one such database, in Illinois, by exploiting a flaw in a web page that allowed citizens to register or change registrations online. In West Virginia and many other states, the database is “air gapped” — cut off from public access. Online registrations are hosted on a separate computer, and new data is hand-carried to the main database on a thumb drive.

The database does have a vulnerability: Some 300 workers in the state’s 55 county clerk’s offices regularly log in to it to update local registrants’ information. Passwords pilfered from those offices could provide a hostile power with an avenue to change or destroy voters’ information. But there, too, security has been tightened. The county clerks regularly meet by phone for briefings on cybersecurity issues like password management.

Last year Mr. Warner participated in cyberwar games — a simulated attack on an American election by a hostile power — staged by the Defending Digital Democracy project at the Harvard University Belfer Center for Science and International Affairs. Mr. Warner was so impressed, he said, that he asked the head of West Virginia’s county clerks’ association to attend a reprise of the exercise.

The war games, he said, taught him that even the most secure election system will be attacked and perhaps even cracked — and that “speed of recovery” is the key to keeping voters’ confidence in the results high.

“It gave me a comfort level as a new secretary of state that, yes, we’re going to be attacked, and when it happens, don’t freak,” he said. “You have to have your detection capabilities up to know when it happens. And when it does, close it down.”