Some finance chiefs say they have plenty of money to invest in their businesses, but shortages in the equipment and people needed for new projects are limiting how much they can take on, leaving a lot of excess cash for buying back stock.

Many U.S. businesses are cash-rich, thanks to strong earnings in recent quarters fueled by the economic recovery. Fundraising rounds during the onset of the coronavirus pandemic and the availability of cheap debt have caused corporate cash holdings to swell. Companies in the S&P 500 held an aggregate of $3.7 trillion in cash and cash equivalents at the end of the second quarter, up from $3.5 trillion a year before, according to S&P Global Market Intelligence, a data provider.

Spending on share buybacks increased much faster than capital expenditures in the first half of the year, after pullbacks in both categories last year amid the pandemic, S&P said in response to a Wall Street Journal data request. Share repurchases at companies in the S&P 500 increased to $370.4 billion, up 29% from the first six months of 2020. Capital spending—which usually goes toward assets such as land, buildings and technology—rose to $337.17 billion, up 4.8% from the year-earlier period.

Government stimulus efforts, such as those launched after the 2008 financial crisis and the coronavirus pandemic, are aimed partly at encouraging companies to invest in their businesses. Businesses, however, have faced criticism for using funds for stock buybacks or dividends. A new bill from Senate Democrats calls for a 2% tax on buybacks.

But having the cash to invest is only one factor. Finance chiefs also have to weigh things like return on capital, debt levels and credit ratings, as well as other spending priorities, such as dividends or mergers and acquisitions. Executives often face a balancing act as they look for the best use of their companies’ funds.

Food maker Hormel Foods Corp. , home-improvement retailer Lowe’s Cos. and freight logistics firm C.H. Robinson Worldwide Inc. are among businesses facing hurdles as they search for ways to spend their cash.

Austin, Minn.-based Hormel, the company behind Spam canned meat, Planters snacks and other brands, was planning more than $300 million in capital expenditures this year, including on expanding a sausage-making plant in Omaha, Neb., finance chief Jim Sheehan said. That target was reduced to about $250 million due to delays in shipments of equipment, Mr. Sheehan said, including some resulting from the continuing microchip shortage.

Jim Sheehan, CFO of Hormel.

Photo: Hormel Foods Corp.

“It wasn’t our intention to decrease our capex; it’s just been difficult to get tools,” Mr. Sheehan said, adding that the company plans to increase capital spending next year.

While share repurchases aren’t a “high priority” for Hormel Foods, Mr. Sheehan said—the company bought back no stock during the first half—they are a welcome use of cash for Lowe’s. The Mooresville, N.C.-based company spent $6.16 billion on repurchasing shares during the first six months of the year, according to S&P, compared with $846 million on capital expenditures.

“It’s not so much a capital constraint problem as it is there’s only so many projects that we can take on and make sure that we deliver on these projects successfully,” Dave Denton, Lowe’s CFO, said. “We’re investing as much as the company can absorb,” he said, adding that the main bottleneck for the business is management’s bandwidth for such projects.

Lowe’s CFO Dave Denton.

Photo: Lowe's Cos.

The company, which is spending on its supply chain as well as its online shopping channels, lifted its annual capital investment threshold to $2 billion for the year ending in January 2022, up from $1.5 billion in 2020, Mr. Denton said. Lowe’s also refinanced its debt and is paying a dividend. “This business throws off a lot of cash,” he said.

The increase in capex and buybacks comes after many companies reduced or halted these programs in the first half of 2020 as the pandemic took hold. “I don’t have to be extremely tight on how I manage cash, like I was in Q2 of 2020,” said Tarek Robbiati, the CFO of technology company Hewlett Packard Enterprise Co., which recently started repurchasing shares and targets buybacks of up to $250 million this quarter.

C.H. Robinson, based in Eden Prairie, Minn., spent $286 million on repurchasing shares and $29.8 million on capital expenditures in the first half. “We are merely constrained by the lack of resources,” said Mike Zechmeister, the company’s CFO, referring to shortages of key personnel needed for capital-spending projects.

The company has the option of hiring more employees or contractors to get additional projects completed, a spokesman said. C.H. Robinson, which employs an asset-light strategy and doesn’t own any ocean liners, trucks or planes, sees share buybacks as a use for “leftover money,” Mr. Zechmeister said.

Other finance chiefs have a similar view. Linde PLC CFO Matt White said the Dublin-based industrial gases company plans to keep sweeping its excess cash into a share-repurchase program.

Anat Ashkenazi, finance chief of Eli Lilly.

Photo: Eli Lilly & Co

Many CFOs said they don’t expect the short-term economic outlook to affect their spending plans. However, changes to tax rules, regulation and other factors could affect decision making, said Anat Ashkenazi, the finance chief of pharmaceutical company Eli Lilly & Co. The company, which plans to spend up to $7.1 billion on research and development this year, has $500 million left to spend from a share-repurchase program authorized in 2018. Lilly’s board recently approved another buyback program totaling $5 billion.

Companies in the S&P 500 have announced 114 new share-repurchase programs so far this year, through Sept. 8, with 108 listing a financial target, S&P said. Those programs, many of which don’t have an expiration date, authorize $358.84 billion in buybacks.

“Share repurchases are easier to pull back from,” in contrast with other forms of capital use, said Howard Silverblatt, a senior index analyst at S&P Dow Jones Indices.

Write to Nina Trentmann at Nina.Trentmann@wsj.com and Mark Maurer at mark.maurer@wsj.com