Skip to content

Commit b01ec9c

Browse files
committed
Remove wmic command from Windows scripts.
1 parent 12586d8 commit b01ec9c

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

sql/process_pg_hist.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
@ECHO OFF
22

33
rem look for process already running, if found get out
4-
wmic process get commandline |find /I "process_pg_hist.bat" |find /C /I "cmd" |find /I "2"
5-
6-
if %ERRORLEVEL% EQU 0 GOTO END
4+
rem Get-Process -Name cmd | Where-Object {$_.CommandLine -like '*process_pg_hist.bat*'} | Measure-Object | Select-Object -ExpandProperty Count
5+
rem if %ERRORLEVEL% EQU 0 GOTO END
76

87
rem cd \json-scada\sql
98

sql/process_pg_rtdata.bat

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
@ECHO OFF
22

33
rem look for process already running, if found get out
4-
wmic process get commandline |find /I "process_pg_rtdata.bat" |find /C /I "cmd" |find /I "2"
5-
6-
if %ERRORLEVEL% EQU 0 GOTO END
4+
rem Get-Process -Name cmd | Where-Object {$_.CommandLine -like '*process_pg_rtdata.bat*'} | Measure-Object | Select-Object -ExpandProperty Count
5+
rem if %ERRORLEVEL% EQU 0 GOTO END
76

87
rem cd \json-scada\sql
98

sql/terminate_pg_hist.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ rem obtain pid from process, then kill it
44

55
set _pid=0
66

7-
FOR /f "tokens=3 delims=," %%G IN (' wmic process get commandline^,processid /FORMAT:csv ^|find /I "process_pg_hist.bat" ^|find /I "cmd" ^|find /V "find" ^|find /V "%~n0"') DO (
7+
FOR /F "tokens=2 delims= " %%G IN ('tasklist /V /FI "IMAGENAME eq cmd.exe" /NH /FO TABLE ^| findstr /I "process_pg_hist.bat" ^| findstr /V /I "terminate_pg_hist.bat"') DO (
88
IF %_pid% EQU 0 (
99
SET _pid=%%G
1010
GOTO BRK

sql/terminate_pg_rtdata.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ rem obtain pid from process, then kill it
44

55
set _pid=0
66

7-
FOR /f "tokens=3 delims=," %%G IN (' wmic process get commandline^,processid /FORMAT:csv ^|find /I "process_pg_rtdata.bat" ^|find /I "cmd" ^|find /V "find" ^|find /V "%~n0"') DO (
7+
FOR /F "tokens=2 delims= " %%G IN ('tasklist /V /FI "IMAGENAME eq cmd.exe" /NH /FO TABLE ^| findstr /I "process_pg_rtdata.bat" ^| findstr /V /I "terminate_pg_rtdata.bat"') DO (
88
IF %_pid% EQU 0 (
99
SET _pid=%%G
1010
GOTO BRK

0 commit comments

Comments
 (0)