Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien

[KIX] RedirectOutput. Log file naar bestand schrijven.

Pagina: 1
Acties:

  • BP_LOZ
  • Registratie: Mei 2006
  • Laatst online: 12-10-2024
Ik ben bezig met het creeren van een logfile d.m.v. Kix. Ik wil verschillende informatie verzamelen bij het inloggen van een gebruiker.
Nu het volgende: Ik wil de draaiende processen ook in deze file hebben. Ik gebruik hiervoor het command "tasklist".
Ik weet hoe ik de output naar een file kan schrijven, ik wil alleen dat het bij DIT log aangevuld wordt.
Hieonder de code. Het gaat om "Process information:"

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
IF EXIST ("\\DOMAIN\PUBLIC\LOGS\HOSTNAME\@WKSTA")
ELSE
MD ("\\DOMAIN\PUBLIC\LOGS\HOSTNAME\@WKSTA")
ENDIF

:LOG
REDIRECTOUTPUT ("\\DOMAIN\PUBLIC\LOGS\HOSTNAME\@WKSTA\@USERID.log", OVERWRITE)
?"----------------------------- START @DATE ------------------------------"
?"-----------------------------------------------------------------------------"
?"Login information:"
?"-----------------------------------------------------------------------------"
?"       Login by        :   @USERID"                                          
?"       Login Date      :   @DATE"                                          
?"       Login Time      :   @TIME"                                             
?"-----------------------------------------------------------------------------"
?"User information:"
?"-----------------------------------------------------------------------------"                                                                                                                                                                                               
?"       Name            :   @FULLNAME"                                         
?"       Username        :   @USERID" 
?"       SID             :   @SID*"
?"-----------------------------------------------------------------------------"
?"Computer information:"    
?"-----------------------------------------------------------------------------"
?"       Workstation     :   @WKSTA"                                    
?"       FQDN            :   @HOSTNAME"                                         
?"       Ip address      :   @IPADDRESS0"                                       
?"       Windows version :   @PRODUCTTYPE"                                      
?"       Service Pack    :   @CSD"   
?"       Memory          :   "  MemorySize (0) "MB"  
?"       Diskspace       :   "GetDiskSpace ("c:") "MB" 
?"-----------------------------------------------------------------------------"
?"Process information:"
?"-----------------------------------------------------------------------------"
SHELL "TASKLIST"
?"-----------------------------------------------------------------------------"
?"Disk information:"
?"-----------------------------------------------------------------------------"
?"       Content of C:"
?"-----------------------------------------------------------------------------"
?""
$basedir = "C:"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
  If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
    ? $basedir+"\"+$name
  EndIf
  $Name = Dir()
Loop
?"-----------------------------------------------------------------------------"
?"       Content of C:\Program Files"
?"-----------------------------------------------------------------------------"
$basedir = "C:\Program Files"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
  If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
    ? $basedir+"\"+$name
  EndIf
  $Name = Dir()
Loop
?"-----------------------------------------------------------------------------"
?"       Content home Directory @userid"
?"-----------------------------------------------------------------------------"
$basedir = "k:"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
  If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
    ? $basedir+"\"+$name
  EndIf
  $Name = Dir()
Loop
?"-----------------------------------------------------------------------------"
?"       Content of Desktop @userid"
?"-----------------------------------------------------------------------------"
$basedir = "k:\Desktop"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
  If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
    ? $basedir+"\"+$name
  EndIf
  $Name = Dir()
Loop
?"-----------------------------------------------------------------------------"
?"       Content of My Documents @userid"
?"-----------------------------------------------------------------------------"
$basedir = "k:\My Documents"
$Name = Dir("$basedir")
While $Name <> "" and @ERROR = 0
  If ($Name <> ".") And ($Name <> "..") And (GetFileAttr($basedir+"\"+$name) & 16)
    ? $basedir+"\"+$name
  EndIf
  $Name = Dir()
Loop
?"------------------------------ END @DATE -------------------------------"

  • Brahiewahiewa
  • Registratie: Oktober 2001
  • Laatst online: 30-09-2022

Brahiewahiewa

boelkloedig

Toch nie zo moeilijk?
code:
1
2
SHELL TASKLIST > C:\TEMP\TASKLIST.TXT
DISPLAY "C:\TEMP\TASKLIST.TXT"

QnJhaGlld2FoaWV3YQ==


  • BP_LOZ
  • Registratie: Mei 2006
  • Laatst online: 12-10-2024
Brahiewahiewa schreef op maandag 26 mei 2008 @ 09:33:
Toch nie zo moeilijk?
code:
1
2
SHELL TASKLIST > C:\TEMP\TASKLIST.TXT
DISPLAY "C:\TEMP\TASKLIST.TXT"
Soms zijn dingen inderdaad makkelijker dan je denkt 8)7

SHELL "cmd.exe /c tasklist>c:\TASKLIST.TXT"
DISPLAY C:\TASKLIST.TXT
DEL C:\TASKLIST.TXT

Maar...
Mijn txt output file ziet er mooi uit
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
System Idle Process              0 Services                   0         12 K
System                           4 Services                   0         56 K
smss.exe                       396 Services                   0        324 K
csrss.exe                      460 Services                   0      1,140 K
wininit.exe                    508 Services                   0         56 K
services.exe                   584 Services                   0      2,812 K
lsass.exe                      596 Services                   0     22,836 K
lsm.exe                        604 Services                   0      2,784 K
svchost.exe                    836 Services                   0      2,896 K
svchost.exe                    908 Services                   0      3,656 K
svchost.exe                    984 Services                   0      5,016 K
svchost.exe                   1028 Services                   0      5,632 K
svchost.exe                   1040 Services                   0     16,404
.....


Maar als ik in mijn log file kijk worden alle rijen achter elkaar gezet like:
code:
1
System Idle Process 0 Services 0 12 K System 4 Services 0 56 K smss.exe 396 Services 0 324 K csrss.exe 460 Services 0 1,140 K wininit.exe 508 Services 0 56 K services.exe 584 Services 0 2,812 K lsass.exe 596 Services 0 22,836 K lsm.exe 604 Services 0 2,784 K svchost.exe 836 Services 0 2,896 K svchost.exe 908 Services 0 3,656 K svchost.exe 984 Services 0 5,016 K svchost.exe 1028 Services 0 5,632 K svchost.exe 1040 Services 0 16,404 K SLsvc.exe 1056 Services 0 1,336 K svchost.exe 1152 Services 0 7,696 K svchost.exe 1224 Services 0 4,260 K svchost.exe 1264 Service


Is hier nog een nette oplossing voor?

[ Voor 70% gewijzigd door BP_LOZ op 26-05-2008 10:35 ]


  • alt-92
  • Registratie: Maart 2000
  • Niet online

alt-92

ye olde farte

> en Redirect handelen dat toch anders af blijkbaar.
Worden de Linefeeds er soms afgesloopt?

ik heb een 864 GB floppydrive! - certified prutser - the social skills of a thermonuclear device