Ultra-reliable and low-latency communication (URLLC) is a pivotal technique for enabling the wireless control over industrial Internet-of-Things (IIoT) devices. By deploying distributed access points (APs), cell-free massive multiple-input and multiple-output (CF mMIMO) has great potential to provide URLLC services for IIoT devices. In this paper, we investigate CF mMIMO-enabled URLLC in a smart factory. Lower bounds (LBs) of downlink ergodic data rate under finite channel blocklength (FCBL) with imperfect channel state information (CSI) are derived for maximum-ratio transmission (MRT), full-pilot zero-forcing (FZF), and local zero-forcing (LZF) precoding schemes. Meanwhile, the weighted sum rate is maximized by jointly optimizing the pilot power and transmission power based on the derived LBs. Specifically, we first provide the globally optimal solution of the pilot power, and then introduce some approximations to transform the original problems into a series of subproblems, which can be expressed in a geometric programming (GP) form that can be readily solved. Finally, an iterative algorithm is proposed to optimize the power allocation based on various precoding schemes. Simulation results demonstrate that the proposed algorithm is superior to the existing algorithms, and that the quality of URLLC services will benefit by deploying more APs, except for the FZF precoding scheme.