我有这个批处理文件,可以在测试计算机上正确运行。但是在我客户的计算机上出现此错误: 错误: 说明 = 该服务配置为在其中运行的可执行程序未实现该服务。 按任意键继续。。 .
正确运行的电脑是Windows 7 Pro 64-bit。给我带来麻烦的计算机是 Windows 7 Pro 32 位。
客户电脑的一些信息: *Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Northside>路径 PATH=C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell 1.0;C:\Program Files\ Common Files\Intuit\QBPOSSDKRuntime
C:\用户\Northside>*
这是我的批处理文件,它在 64 位 Windows 7 Pro 上运行时没有错误,但在 32 位 Windows 7 Pro 上运行时没有错误。
任何帮助让它工作或使用 Powershell 命令的“for /F”skip=2 tokens=2 delims=,”%%p in ('wmic logicaldisk where drivetype^=2 get deviceid^,volumename /format :csv') do (if EXIST "%%p\smart04.mdb" (" 对于这一行将不胜感激。
@echo off
rem This batch file is for use with the USb Thumb Drives
rem Save this file as "Upload Frayser.bat"
rem modified for Windows 7 on April 18, 2023
Echo Upload Frayser
echo.
for /F "skip=2 tokens=2 delims=," %%p in ('wmic logicaldisk where drivetype^=2 get deviceid^,volumename /format:csv') do (if EXIST "%%p\smart04.mdb" (
@echo Copying database file
COPY %%pSMART02.MDB n:\SMART\DATA\FRAYSER\SMART1.MDB
@echo Copying automat.in file
copy %%pautomat.in m:\
@echo off
@echo.
rem echo OK to remove USB Stick!
rem powershell write-host -fore Cyan Please eject drive before removing.
start C:\"Program Files"\USB_Disk_Eject.exe /REMOVELETTER %%p
powershell write-host -fore Cyan OK to remove USB Stick!
@echo.
rem pause> nul | set /p "=Click on the X at the top right corner to close after you have removed the USB drive. "
@echo Click on the X at the top right corner to close
pause> nul | set /p "= after you have removed the USB stick."
exit /b
)
powershell write-host -fore Cyan Cannot find frayser database file. Sorry, no files were copied!
rem echo Cannot find database file. Sorry, no files were copied!
start C:\"Program Files"\USB_Disk_Eject.exe /REMOVELETTER %%p
@echo.
powershell write-host -fore Cyan OK to remove USB Stick!
@echo.
rem pause> nul | set /p "=Click on the X at the top right corner to close after you have removed the USB stick. "
@echo Click on the X at the top right corner to close
pause> nul | set /p "= after you have removed the USB stick."
exit /b
)
pause
Expecting the "for /F "skip=2 tokens=2 delims=," %%p in ('wmic logicaldisk " line to run with giving the executable program that this service is configured to run in in does not implement the service 。”错误。
根据您显示的错误消息,相应的注册表位置似乎缺少 Windows Management Instrumentation 服务。
要附加它,我建议您创建一个包含以下内容的 PowerShell 脚本:
$key = Get-Item "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost\"
$values = $key.GetValue("netsvcs")
$values += "winmgmt"
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost\" "netsvcs" $values -Type MultiString
然后,在“有问题的”Windows 7 Pro 计算机上,右键单击它并选择“以管理员身份运行”选项。
如果成功,您应该能够运行脚本的改进版本,包括 WMIC.exe 实用程序。