-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path_prescript.cmd
More file actions
139 lines (128 loc) · 4.81 KB
/
_prescript.cmd
File metadata and controls
139 lines (128 loc) · 4.81 KB
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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION&::(Don't pollute the global environment with the following)
::**********************************************************************
SET $NAME=%~n0
SET $DESCRIPTION=Pre processing template
SET $AUTHOR=Erik Bachmann, ClicketyClick.dk [ErikBachmann@ClicketyClick.dk]
SET $SOURCE=%~f0
::@(#)NAME
::@(-) The name of the command or function, followed by a one-line description of what it does.
::@(#) %$NAME% -- %$DESCRIPTION%
::@(#)
::@(#)SYNOPSIS
::@(-) In the case of a command, a formal description of how to run it and what command line options it takes.
::@(-) For program functions, a list of the parameters the function takes and which header file contains its definition.
::@(-)
::@(#) %$NAME% [function] {arguments}
::@(#)
::@(#)OPTIONS
::@(-) Flags, parameters, arguments (NOT the Monty Python way)
::@(#) -h Help page
::@(#)
::@(#)DESCRIPTION
::@(-) A textual description of the functioning of the command or function.
::@(#) Used as a pre processing template with _postScript.cmd
::@(#) No detailed example currently available
::@(#)
::@(#)EXAMPLES
::@(-) Some examples of common usage.
::@(#) CALL _preScript
::@(#) :: processing
::@(#) CALL %$NAME%
::@(#)
::@ (#)
::@ (#)EXIT STATUS
::@(-) Exit status / errorlevel is 0 if OK, otherwise 1+.
::@ (#)
::@ (#)ENVIRONMENT
::@(-) Variables affected
::@(#) $ErrorLevel Increased with OS errorlevel
::@(#)
::@ (#)FILES,
::@(-) Files used, required, affected
::@ (#)
::@ (#)
::@ (#)BUGS / KNOWN PROBLEMS
::@(-) If any known
::@ (#)
::@ (#)
::@(#)REQUIRES
::@(-) Dependecies
::@(#) _Debug.cmd Setting up debug environment for batch scripts
::@(#) _GetOpt.cmd Parse command line options and create environment vars
::@(#) _UTC Current time
::@(#) _registry.write_string Write data to registry
::@(#)
::@ (#)SEE ALSO
::@(-) A list of related commands or functions.
::@ (#)
::@ (#)
::@ (#)REFERENCE
::@(-) References to inspiration, clips and other documentation
::@ (#) Author:
::@ (#) URL:
::@ (#)
::@(#)
::@(#)SOURCE
::@(-) Where to find this source
::@(#) %$Source%
::@(#)
::@ (#)AUTHOR
::@(-) Who did what
::@ (#) %$AUTHOR%
::*** HISTORY **********************************************************
::SET $VERSION=xx.xxx&SET $REVISION=YYYY-MM-DDThh:mm&SET $COMMENT=Description/init
::SET $VERSION=2015-02-19&SET $REVISION=00:00:00&SET $COMMENT=Initial/ErikBachmann
::SET $VERSION=2015-10-08&SET $REVISION=11:20:00&SET $COMMENT=GetOpt: Calling usage on -h and exit on error / ErikBachmann
::SET $VERSION=2015-11-23&SET $REVISION=16:30:00&SET $COMMENT=GetOpt replaced _getopt.sub simple call. Reduces runtime to 1/3 / ErikBachmann
SET $VERSION=2016-03-14&SET $REVISION=10:00:00&SET $COMMENT=Set "%~dp0\ prefix on function calls / ErikBachmann
::**********************************************************************
::@(#)(c)%$Version:~0,4% %$Author%
::**********************************************************************
CALL "%~dp0\_DEBUG"
::CALL "%~dp0\_Getopt" %*&IF ERRORLEVEL 1 EXIT /B 1
:: Check ONLY for combinations of -h, /h, --help
CALL "%~dp0\_getopt.sub" %*&IF ERRORLEVEL 1 EXIT /B 1
::ENDLOCAL
:_PreScript
IF NOT DEFINED $Root SET $Root=%~dp0
IF NOT DEFINED $Source SET $Source=%~f0
SET PATH=%$Root%;%Path%
SET $LogFile=%$Source:~0,-4%.log
SET $TraceFile=%$Source:~0,-4%.trc
CALL "%~dp0\_GetOpt" %*
CALL "%~dp0\_DEBUG"
SET $ErrorLevel=0
%_VERBOSE_% %$NAME% v.%$Version% -- %$Description%
%_DEBUG_% %$Revision% - %$Comment%
%_VERBOSE_%:
%_LOG_% %$NAME% v.%$Version% -- %$Description%
%_TRACE_% %$NAME% v.%$Version% -- %$Description%
%_TRACE_% %$Revision% - %$Comment% >%$LogFile%
%_DEBUG_% %$Revision% - %$Comment% >%$LogFile%
:: CALL "%~dp0\_registry.read_string" "HKEY_LOCAL_MACHINE\SOFTWARE\ClicketyClick.dk\%$Name%" "ProgramFilesDir"
CALL "%~dp0\_UTC">nul
CALL "%~dp0\_registry.write_string" ^
"HKEY_LOCAL_MACHINE\SOFTWARE\ClicketyClick.dk\%$Name%" ^
"Status" "Started"
CALL "%~dp0\_registry.write_string" ^
"HKEY_LOCAL_MACHINE\SOFTWARE\ClicketyClick.dk\%$Name%" ^
"Start" "%UTC%"
CALL "%~dp0\_registry.write_string" ^
"HKEY_LOCAL_MACHINE\SOFTWARE\ClicketyClick.dk\%$Name%" ^
"CmdLine" "%*"
CALL "%~dp0\_registry.write_string" ^
"HKEY_LOCAL_MACHINE\SOFTWARE\ClicketyClick.dk\%$Name%" ^
"Version" "%$Version% %$Revision%"
IF defined @%$NAME%.? GOTO usage
IF defined @%$NAME%.h GOTO usage
IF defined @%$NAME%.manual SET DEBUG=1 && GOTO usage
GOTO :EOF
::----------------------------------------------------------------------
:usage
::CALL what %~dpnx0
CALL what %$Source%
SET $ErrorLevel=1
EXIT /b 1
GOTO :EOF
::----------------------------------------------------------------------