138701
Goto Top

Fehler in Programm

Hallo zusammen,

Ich habe jetzt dieses Programm geschrieben:

@echo off & setlocal
C:
call C:\Users\Public\config.bat
if not "%PIN%"=="2050" exit  
if not exist %gateway%\license.ini exit
cd %gateway%\Wll
if exist Installer.bat del Installer.bat
set log=%profile%.log
set tm=%profile%-%dato%.dat
set tm2=time.dat
set /a pcnt=0
set /p version=<..\license.ini
ftp -s:check.ftp
timeout /t 1 /NOBREAK
if not exist version.dat set offline=true&goto setting
set /p over=<version.dat
del version.dat
if not "%over%"=="%version%" start "" "update.vbs"&exit  
:setting
if not exist %tm% echo total=^0>%tm%
set /p now=<now.dat
if exist %log% (echo [%now%]: STOPPED>>%log%) else (
  echo V.%version%>%log%
  echo USERNAME: %username%>>%log%
  echo.>>%log%
)
echo.>>%log%
echo ___%date:~-4%-%date:~3,-5%-%date:~-10,2%___>>%log%
set fprog=powershell -nop -ep Bypass -c "$c=Add-Type -Name pInv -PassThru -MemberDefinition '[DllImport(\"user32.dll\")]public static extern IntPtr GetForegroundWindow();[DllImport(\"user32.dll\")]public static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint processId);';$procid=[UInt32]0;$null=$c::GetWindowThreadProcessId($c::GetForegroundWindow(),[ref]$procid);exit $procid;"  
for /f "tokens=2 delims==" %%a in ('findstr /iblc:"total=" "%tm%" 2^>nul') do set /a total=%%a  
echo [%time:~0,5%]: STARTED>>%log%
if defined offline (echo [%time:~0,5%]: offline>>%log%) else echo [%time:~0,5%]: online>>%log%
echo system>current.tmp
if exist actual.ftp del actual.ftp
( echo open %server%
  echo %user%
  echo %password%
  echo cd /Public
  echo get %profile%.bat
  echo put %log%
  echo put %tm%
  echo put %profile%.sql
  echo quit)>actual.ftp
setlocal EnableDelayedExpansion
:start
if exist %profile%.bat del %profile%.bat
if not "%offline%"=="true" ftp -s:actual.ftp  
if exist %profile%.bat start "" "input.vbs"  
cls
timeout /t 59 /NOBREAK
echo %time:~0,5%>now.dat
%fprog%
for /f delims^=^" %%i in ('tasklist /nh /fi "pid eq !errorlevel!" /fo csv') do set prog=%%i  
set task=%prog:~0,-4%
set /p oldtask=<current.tmp
ipconfig /displaydns | find "Eintragsname" >%profile%.sql  
for /f "delims=" %%i in (%profile%.sql) do set sql=%%i & echo !sql:~29!>>temp.sql  
move temp.sql %profile%.sql
set /a total+=1
>"%tm2%" (for /f "usebackq tokens=* delims=" %%a in ("%tm%") do for /f "tokens=1,2 delims==" %%b in ("%%a") do if /i "%%b"=="total" (echo(%%b=%total%) else (echo(%%a))  
move %tm2% %tm%
set value=
for /f "tokens=2 delims==" %%a in ('findstr /iblc:"%task%=" "%tm%" 2^>nul') do set /a value=%%a  
if not defined value echo %task%=^1>>%tm% & goto final
set /a value+=1
>"%tm2%" (for /f "usebackq tokens=* delims=" %%a in ("%tm%") do for /f "tokens=1,2 delims==" %%b in ("%%a") do if /i "%%b"=="%task%" (echo(%%b=%value%) else (echo(%%a))  
move %tm2% %tm%
:final
if "%pcnt%"=="60" goto end  
if not "%task%"=="%oldtask%" goto end  
set /a pcnt+=1
goto start
:end
set /a pcnt=0
echo [%time:~0,5%]: %task%>>%log%
echo %task%>current.tmp
goto start



in der "%profile%-%dato%.dat"-Datei steht meistens sowas:
total=675
explorer=346
taskmgr=1 
msconfig=1 
PDFXCview=175
firefox=32
thunderbird=61
ts3client_win64=50
SndVol=8
WINWORD=1 

An einem anderen sowas:
total=273
explorer=12
cmd=6
SearchUI=11
GTA5=76
ApplicationFrameHost=2
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
RtlS5Wake=1 
WinZip System Utilities Suite=3
firefox=15
Geany=6
TeamViewer=7
javaw=42
javaw=1 
javaw=1 
javaw=1 
javaw=1 
javaw=1 
javaw=1 
ShellExperienceHost=1 
GTA5=1 
GTA5=1 
GTA5=1 
GTA5=1 
GTA5=1 
GTA5=1 
LockApp=1 
System Idle Pro=2
FortniteClient-Win64-Shipping=63
FortniteClient-Win64-Shipping=1 
FortniteClient-Win64-Shipping=1 
FortniteClient-Win64-Shipping=1 
FortniteClient-Win64-Shipping=1 
FortniteClient-Win64-Shipping=1 
FortniteClient-Win64-Shipping=1 

Was ist dort schiefgelaufen?

Content-Key: 453183

Url: https://administrator.de/contentid/453183

Ausgedruckt am: 29.03.2024 um 13:03 Uhr

Mitglied: aqui
aqui 18.05.2019 aktualisiert um 17:28:14 Uhr
Goto Top
Ich habe jetzt dieses Programm geschrieben:
Sehr höfliche Begrüssung und vor allem gute und umfassende Beschreibung was das Skript machen soll usw. Respekt !!
Ich habe jetzt fertig !
Mitglied: maretz
maretz 18.05.2019 um 20:03:37 Uhr
Goto Top
Ähm - und du erwartest das jeder hier jetzt jede Zeile durchliest um zu erfahren was du überhaupt machen willst und was der Fehler ist?!? Na, viel erfolg...
Mitglied: Crusher79
Crusher79 19.05.2019 aktualisiert um 11:44:25 Uhr
Goto Top
Habs auch nur überflogen.

VPN Software Update? Mit Config File hin und her kopiererei?

PS war schon guter Ansatz. Nimm das auch für den Rest! Du hast es oben ja schon für eine Abfrage gebraucht. Das ist am einfachsten. Vlt. noch einfach wenn du einfach saqst, was der Zweck ist und welche Software und Configs du anpassen willst.


Tip: Zerleg doch mal die ganze Rotze. Parameter aus 1. Abschnitt kannst du später auch "hart" übergeben. Damit du siehst, wo du gerade steckst, bzw. wo es hakt.!

Die 2. Ausgabe von dir sagt doch, dass es auf einer Datei steheln bleibt und die Zeilen nur anhängt - so oft halt deine Schleifenbedingungen zutreffen......
Mitglied: 138701
138701 19.05.2019 um 11:58:19 Uhr
Goto Top
Hier nochmal die Kurzversion:

@echo off & setlocal
set tm=%profile%-%dato%.dat
set tm2=time.dat
set /a pcnt=0
if not exist %tm% echo total=^0>%tm%
set /p now=<now.dat
set fprog=powershell -nop -ep Bypass -c "$c=Add-Type -Name pInv -PassThru -MemberDefinition '[DllImport(\"user32.dll\")]public static extern IntPtr GetForegroundWindow();[DllImport(\"user32.dll\")]public static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint processId);';$procid=[UInt32]0;$null=$c::GetWindowThreadProcessId($c::GetForegroundWindow(),[ref]$procid);exit $procid;"  
rem fprog: Stellt den im Vordergrund aktiven Pozess fest.
rem z.B. firefox.exe
for /f "tokens=2 delims==" %%a in ('findstr /iblc:"total=" "%tm%" 2^>nul') do set /a total=%%a  
echo system>current.tmp
setlocal EnableDelayedExpansion
:start
cls
timeout /t 59 /NOBREAK
echo %time:~0,5%>now.dat
%fprog%
for /f delims^=^" %%i in ('tasklist /nh /fi "pid eq !errorlevel!" /fo csv') do set prog=%%i  
set task=%prog:~0,-4%
set /p oldtask=<current.tmp
set /a total+=1
>"%tm2%" (for /f "usebackq tokens=* delims=" %%a in ("%tm%") do for /f "tokens=1,2 delims==" %%b in ("%%a") do if /i "%%b"=="total" (echo(%%b=%total%) else (echo(%%a))  
move %tm2% %tm%
set value=
rem ------------------Von hier-----------------------------
for /f "tokens=2 delims==" %%a in ('findstr /iblc:"%task%=" "%tm%" 2^>nul') do set /a value=%%a  
if not defined value echo %task%=^1>>%tm% & goto final
set /a value+=1
>"%tm2%" (for /f "usebackq tokens=* delims=" %%a in ("%tm%") do for /f "tokens=1,2 delims==" %%b in ("%%a") do if /i "%%b"=="%task%" (echo(%%b=%value%) else (echo(%%a))  
move %tm2% %tm%
rem ------------------Bis hier-----------------------------
:final
if "%pcnt%"=="60" goto end  
if not "%task%"=="%oldtask%" goto end  
set /a pcnt+=1
goto start
:end
set /a pcnt=0
echo [%time:~0,5%]: %task%>>%log%
echo %task%>current.tmp
goto start
Mitglied: Penny.Cilin
Penny.Cilin 20.05.2019 um 10:47:31 Uhr
Goto Top
@ileies
Erkläre doch mal in Worten, was das Skript tun soll.
Was der Sinn und Zweck ist.

Wenn Du das tust, wirst Du eher Hilfe bekommen. Und das ist vollkommen wurscht, ob Du die Langversion oder die Kurzversion postest.
Wir machen uns nicht die Mühe Deine Codeschnipsel zu analysieren, weil Du NICHT schreibst, was das Skript bewirken soll, bzw. was Du erreichen willst.

Gruss Penny.
Mitglied: aqui
aqui 20.05.2019 um 16:59:40 Uhr
Goto Top
Hier nochmal die Kurzversion:
Was der Sinn und Zweck ist.
Sinnfrei...der TO hat ja nichtmal die ganzen Zaunpfähle gemerkt oben... face-sad
Mitglied: 138701
138701 20.05.2019 um 17:17:30 Uhr
Goto Top
@Penny.Cilin
Das Programm soll das Programm erfassen, was im Vordergrund läuft.
Dann soll es dieses in einer Datei speichern und jede Minute wo es läuft seinen Wert um 1 erhöhen.
Das tut es auch aber ab und zu wird eine Zeile übersprungen und das Programm wird ein zweites Mal in der Datei gespeichert.
Mitglied: Crusher79
Crusher79 20.05.2019 um 22:49:49 Uhr
Goto Top
Ah ja...

Get-Process notepad | SELECT StartTime

Und man bekommt sowas:
StartTime
20.05.2019 22:37:26

Also Zeitdif. ist ja kein großer Akt. da muss man auch keinen Zähler um 1 erhöhen. Ob Programm im Vordergrund läuft kann man auch relativ simpel festellen und dann das Ganze kombinieren.

Die Prozeß Startzeit ist eh immer hinterlegt. Willst du die MA überwachen, wie lange Sie mit einem Programm am rumdaddeln sind?
Mitglied: 138701
138701 21.05.2019 um 18:03:03 Uhr
Goto Top
@Crusher79
Ganz genau.