HP raised its annual profit outlook, boosted by strong sales of computers to businesses, but warned that Russia’s invasion of Ukraine would dent its bottom line this quarter.

The company estimated a hit of 2 cents to 3 cents to its per-share profit this quarter related to the invasion of Ukraine.

For the quarter, it projected a profit of 95 cents to $1.01 a share, or $1.02 to $1.08 a share as adjusted, roughly in line with analysts’ forecasts, according to FactSet.

We have stopped shipments of all the prohibited products,” Chief Executive Enrique Lores said, referring to sanctions placed on Russia. He added that HP expects to mitigate the impact in the second half of the year.

The roughly $17 billion in net revenue for the January-ended quarter beat the analyst consensus and reflected sales growth across notebooks and desktops along with a continued recovery in workstations. Analysts polled by FactSet expected $16.52 billion.

Shares of HP closed Monday at $34.36, off less than 1% for the day and were flat in after-hours trading. The stock is down 8.8% so far this year.

Mr. Lores said HP had seen some supply-chain improvement but that the print business is seeing the impact from earlier factory lockdowns and expects shortages to continue the rest of the year. Still, he said: “We expect that we will be able to reduce backlog.”

Printing revenue fell 4% to $4.83 billion, missing analysts’ $4.91 billion forecast, according to FactSet.

Mr. Lores pointed to strength on the commercial side, as offices reopen and companies invest in equipment to allow for hybrid work arrangements.

Employees need higher-end PCs to be able to connect, to communicate, with better cameras, more memory, better displays,” he said.

Commercial PC revenue rose 26% in the latest quarter, the company said, while consumer PC sales declined 1%.

Personal-computer sales have seen a strong rebound during the pandemic, and in 2021 registered the strongest growth in nearly a decade.

PC vendors like HP have said demand would trend even higher were it not for supply-chain issues. They cite hybrid work and education arrangements as changes that are expected to continue to lift sales.

Top PC vendor Lenovo Group Ltd. said last week that the market is expected to remain solid and shift to commercial and premium segments, which should drive up average selling prices.

Dell Technologies Inc. last week reported a record year for its PC business and projected another strong performance this business year. But it also noted that supply-chain issues worsened in the fourth quarter in servers and storage and are expected to remain during the first half of the year.

There are supply constraints throughout the industry that are impacting us and are causing incremental cost,” Dell Chief Financial Officer Tom Sweet said in a conference call to discuss the company’s performance. “So there has been some pressure on gross margin.”

Gross margin is expected to “trend up gradually over the course of the year,” Mr. Sweet said, though “there’s work to do to get it there.”

Similarly, HP had pointed to revenue growth and margin expansion for the personal-systems segment, which includes the PC business, with a shift to commercial, premium and peripherals like microphones and headsets.

Peripherals revenue rose 40% in the latest quarter, driven by gaming, the company said.

We have seen that gamers spend five times more money on peripherals than they do in their computers,” Mr. Lores said.

HP’s first-quarter profit rose to $1.09 billion, or 99 cents a share. On an adjusted basis, profit rose to $1.10 a share.

The results beat HP’s forecast and analysts’ projections.

HP said it now expects to make a profit of $3.87 to $4.07 a share this year, or $4.18 to $4.38 as adjusted, compared with its previous view of $3.86 to $4.06 a share, or $4.07 to $4.27 a share as adjusted. It still expects to generate at least $4.5 billion in free cash flow.