Bonjour,

Je cherche de la documentation sur des batchs/scripts en dos...

Attention, pas des simples commandes dos mais des scripts complexes...

Existe t-il des sites,etc... ?

Quelqu'un peut-il m'aider ?

Voici un exemple de code que j'essaie de comprendre :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
@echo on
rem  - if reg_exit is not defined then end (not yet scanned)
rem  - if reg_exit >=8 then end (stopped by CC)
rem  - if reg_actnr >=4 then end (scan ended)
rem  - if reg_actnr < 4 then if ko file does not exist then start clean
rem  - if reg_actnr < 4 then if ko file does     exist then do not handle
rem  - if reg_actnr = 1 then recheck (and clean) else clean

setlocal
set copycmd=/Y
set name=%~1

set shardrv=\\inf01atriusm04\etrav$


REM Check if handling is still busy
if not exist %proc_dir%%name%.txt goto :end_busy
echo %date% %time% %name% handling busy>> "%logstatus%%name%.txt"
goto :end
:end_busy
echo %date% %time%>%proc_dir%%name%.txt


REM Check if correct machinename (no spc, nor .)
call :compare_name %name% %name:.= %
if %nameerror% NEQ 1 goto :machinename_ok
echo %date% %time% %name% not permitted>> "%logstatus%%name%.txt"
goto :end_handle
:machinename_ok


REM Check if offline
for /F "tokens=1,2,3,6 delims=:	 " %%i in ('ping -a -n 1 %name%') do (
 if "%%i" EQU "Pinging" set given_host=%%j
 if "%%i" EQU "Reply"   set ip=%%k
 if "%%i" EQU "Reply"   set ttl=%%l
)
if defined ip goto :machine_found
echo %date% %time% %name% not found>> "%logstatus%%name%.txt"
goto :end_handle
:machine_found

REM Check if on protected subnet
if defined ttl if /I "%ttl%" NEQ "unreachable." goto :machine_noprot
echo %date% %time% %name% unreachable>> "%logstatus%%name%.txt"
goto :end_handle
:machine_noprot

REM Check if alias is used
call :compare_name %name% %given_host:.= %
if %nameerror% NEQ 1 goto :machine_noalias
echo %date% %time% %name% alias used (%given_host%)>> "%logstatus%%name%.txt"
goto :end_handle
:machine_noalias

REM Check if WINS problem
for /f "tokens=1,2" %%i in ('ping -n 1 -a %ip%') do (
  if "%%i" EQU "Pinging" set found_host=%%j
)
call :compare_name %name% %found_host:.= %
if %nameerror% NEQ 1 goto :machine_winsok
call :compare_name %ip% %found_host%
if %nameerror% NEQ 1 goto :machine_winsok
echo %date% %time% %name% WINS problem (%found_host%)>> "%logstatus%%name%.txt"
goto :end_handle
:machine_winsok


REM Get domain info
set dom= 
for /F "tokens=1-3 skip=8" %%i in ('nbtstat -a %ip%') do if "%%j%%k" EQU "<00>GROUP" set dom=%%i
if /i "%dom%" EQU "MSNET" if /i "%userdomain%" EQU "MSNET" goto :cont_dom
if /i "%dom%" NEQ " " if /i "%dom%" NEQ "MSNET" if /i "%userdomain%" NEQ "MSNET" goto :cont_dom
echo %date% %time% %name% %name% %dom%, check with other loop (%userdomain%)>> "%logstatus%%name%.txt"
goto :end_handle
:cont_dom


REM Check disk accessible and get space
for /F "tokens=1,2 delims=:= " %%i in ('%~dp0..\_PushTools\DiskSpace \\%ip%\admin$\system32\') do (
  set disk_rtn=%%i
  set iFree=%%j
)
if "%disk_rtn%" NEQ "Error" goto :disk_access
echo %date% %time% %name% not accessible (errorcode %iFree%)>> "%logstatus%%name%.txt"
goto :end_handle
:disk_access


REM Check if console
if not exist \\%ip%\admin$\console.flag goto :no_console
set %date% %time% %name% is console
goto :machine_handled
:no_console




REM Decide what to do

set reg_flags=-;-;--;-;- -;- -
for /f "skip=2 tokens=2* delims=	 " %%i in ('%~dp0..\_Pushtools\reg query \\%name%\HKLM\SOFTWARE\ICT\PackageLog\FIX_APP_ePP /v StatusFlags 2^>nul') do set reg_flags=%%j
call :set_subflags %reg_flags:;= %

if defined reg_exit goto :regs_flags_ok
set result=%date% %time% %name% %dom% unhandled statusflags (%reg_flags%)
goto :machine_handled
:regs_flags_ok

if %reg_exit% LSS 8 goto :not_stopped_cc
set result=%date% %time% %name% scan stopped by CC or VCSD
goto :machine_handled
:not_stopped_cc

if %reg_actnr% LSS 4 goto :not_yet_handled
set result=%date% %time% %name% scan ended (reg_flags=%reg_flags%)
goto :machine_handled
:not_yet_handled

if not exist \\inf01atriusm04\etrav$\PP5\log\%name%_ko.log goto :no_ko_file
echo %date% %time% %name% compare problem>> "%logstatus%%name%.txt"
goto :end_handle
:no_ko_file


:cont_inst
rem Set waittime
rem  default : 0 (no wait, when exceeded go & no exceed msg)
rem  use given time except when force asked (lines exceeded) : wait x seconds, when exceeded go & give exceed message
rem  use 1 when force asked (lines exceeded) : wait 1 second, when exceeded go & give exceed message
rem  a negative value means : wait -x seconds, when exceeded no go  & give exceed message
set l_wait=0
if "%5" NEQ ""  set l_wait=%5
if "%3" EQU "1" set l_wait=1

rem Decide what message to give to the user
set pp_msg=%shardrv%\PP5\commands\PP5aut_re.txt
if %reg_actnr% NEQ 1 set pp_msg=%shardrv%\PP5\commands\PP5aut_cl.txt

rem Make the compare log file if not already fone
if %reg_actnr% EQU 1 if not exist %shardrv%\PP5\log\%name%_r.log ren %shardrv%\PP5\log\%name%.log %name%_r.log

echo %date% %time% %name% handling with reg_actnr=%reg_actnr%>> "%logstatus%%name%.txt"
%~dp0..\_PushTools\psexec \\%name% -d -s -c -f %~dp0..\_PushTools\EssmMsg.exe %username% %shardrv% noforce %pp_msg% %l_wait% %shardrv%\PP5\LogInstClean\%cycle% %shardrv%\PP5\commands\PP5.bat "--autermlh"
if %errorlevel% EQU 8 echo %date% %time% %name% already busy>> "%logstatus%%name%.txt"
goto :end_handle


:machine_handled
echo %result%>> "%logstatus%%name%.txt"
echo %result%>  "%log_dir%%name%.txt"
move "%logstatus%%name%.txt" "%logstatus%Hist\%name%.txt"



:end_handle
if exist %proc_dir%%name%.txt del %proc_dir%%name%.txt

:end
goto :eof

rem =====================================================================================================
:compare_name
set nameerror=0
if /I "- %1 -" NEQ "- %2 -" set nameerror=1
goto :eof

:set_subflags
set reg_actnr=%1
set reg_exit=%2
set reg_exc=%3
set reg_version=%4
set reg_startts=%5 %6
set reg_endts=%7 %8
goto :eof
Merci
++