rtoss - Blame information for rev 333

Subversion Repositories:
Rev:
Rev Author Line No. Line
225 roytam 1 !include "FileFunc.nsh"
2 !include "StrFunc.nsh"
3 !include "LogicLib.nsh"
4  
228 roytam 5 !packhdr "$%TEMP%\exehead.tmp" 'upx --best "$%TEMP%\exehead.tmp"'
6  
225 roytam 7 Var SetupName
8  
9 OutFile "shellrunner.exe"
10 Name $SetupName
11 Icon "gear_02.ico"
227 roytam 12 SetCompressor LZMA
225 roytam 13  
231 roytam 14 ; Comment out next lines for ANSI build
232 roytam 15 Unicode true ; make a Unicode installer
231 roytam 16 ;!define UTF16Script
227 roytam 17  
225 roytam 18 RequestExecutionLevel user
19  
20 Var scriptname
231 roytam 21 Var parseverbose
232 roytam 22 Var utf8script
227 roytam 23 Var argvc
24 Var argv0
25 Var argv1
26 Var argv2
27 Var argv3
28 Var argv4
29 Var argv5
30 Var argv6
31 Var argv7
32 Var argv8
33 Var argv9
231 roytam 34 Var lineno
333 roytam 35 Var skiplines
225 roytam 36  
230 roytam 37 Var retval
38 Var var0
39 Var var1
40 Var var2
41 Var var3
42 Var var4
43 Var var5
44 Var var6
45 Var var7
46 Var var8
47 Var var9
48  
231 roytam 49 !define RetvalToVar "!insertmacro RetvalToVar"
50 !macro RetvalToVar var
51 Push $retval
52 Pop ${var}
53 !macroend
54  
55 !define VarToRetval "!insertmacro VarToRetval"
56 !macro VarToRetval var
57 Push ${var}
58 Pop $retval
59 !macroend
60  
225 roytam 61 ; init StrRep macro/function outside everything first
62 ${StrRep}
63 ${StrTok}
64  
231 roytam 65 /*
66 !define CharToASCII "!insertmacro CharToASCII"
67  
68 !macro CharToASCII AsciiCode Character
69 Push "${Character}"
70 Call CharToASCII
71 Pop "${AsciiCode}"
72 !macroend
73  
74 Function CharToASCII
75 Exch $0 ; given character
76 Push $1 ; current character
77 Push $2 ; current Ascii Code
78  
79 StrCpy $2 1 ; right from start
80 Loop:
81 IntFmt $1 %c $2 ; Get character from current ASCII code
82 ${If} $1 S== $0 ; case sensitive string comparison
83 StrCpy $0 $2
84 Goto Done
85 ${EndIf}
86 IntOp $2 $2 + 1
87 StrCmp $2 255 0 Loop ; ascii from 1 to 255
88 StrCpy $0 0 ; ASCII code wasn't found -> return 0
89 Done:
90 Pop $2
91 Pop $1
92 Exch $0
93 FunctionEnd
94 */
95  
232 roytam 96 !define FileReadUTF8 "!insertmacro FileReadUTF8"
97 !macro FileReadUTF8 handle output
98 Push "${handle}"
99 Call FileReadUTF8
100 Pop "${output}"
101 !macroend
102 Function FileReadUTF8
103 Push $0
104 Exch
105 Pop $0 ; handle
106 Push $1 ; Out
107 Push $2 ; read byte 1
108 Push $3 ; read byte 2
109  
110 StrCpy $1 ""
111 SetErrorLevel 0
112 IfErrors done
113 read:
114 FileReadByte $0 $2
115 ${If} $2 = 0x0a
116 ${OrIf} $2 == ''
117 Goto done
118 ${ElseIf} $2 = 0x0d
119 Goto read
120 ${ElseIf} $2 < 0x80
121 IntFmt $2 "%c" $2
122 StrCpy $1 "$1$2"
123 ${ElseIf} $2 >= 0xc0
124 ${AndIf} $2 < 0xe0
125 IntOp $2 $2 & 0x1f
126 IntOp $2 $2 << 6
127 FileReadByte $0 $3
128 IntOp $3 $3 & 0x3f
129 IntOp $2 $2 + $3
130 IntFmt $2 "%c" $2
131 StrCpy $1 "$1$2"
132 ${ElseIf} $2 >= 0xe0
133 ${AndIf} $2 < 0xf0
134 IntOp $2 $2 & 0x0f
135 IntOp $2 $2 << 6
136 FileReadByte $0 $3
137 IntOp $3 $3 & 0x3f
138 IntOp $2 $2 + $3
139 IntOp $2 $2 << 6
140 FileReadByte $0 $3
141 IntOp $3 $3 & 0x3f
142 IntOp $2 $2 + $3
143 IntFmt $2 "%c" $2
144 StrCpy $1 "$1$2"
145 ${ElseIf} $2 >= 0xf0
146 ${AndIf} $2 < 0xf7
147 IntOp $2 $2 & 0x07
148 IntOp $2 $2 << 6
149 FileReadByte $0 $3
150 IntOp $3 $3 & 0x3f
151 IntOp $2 $2 + $3
152 IntOp $2 $2 << 6
153 FileReadByte $0 $3
154 IntOp $3 $3 & 0x3f
155 IntOp $2 $2 + $3
156 IntOp $2 $2 << 6
157 FileReadByte $0 $3
158 IntOp $3 $3 & 0x3f
159 IntOp $2 $2 + $3
160 IntFmt $2 "%c" $2
161 StrCpy $1 "$1$2"
162 ${EndIf}
163  
164 Goto read
165  
166 done:
167 ${If} $1 != ''
168 ClearErrors
169 ${EndIf}
170 Pop $3
171 Pop $2
172 Push $1
173 Exch
174 Pop $1
175 Exch
176 Pop $0
177 FunctionEnd
178  
179  
227 roytam 180 ; SplitArg by Anders
181 ; http://stackoverflow.com/a/19644470/145278
182 Function SplitArg
183 Exch $0 ; str
184 Push $1 ; inQ
185 Push $3 ; idx
186 Push $4 ; tmp
187 StrCpy $1 0
188 StrCpy $3 0
189 loop:
190 StrCpy $4 $0 1 $3
231 roytam 191 ; ${CharToASCII} $R9 $1
192 ; DetailPrint "'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 193 ${If} $4 == '"'
194 ${If} $1 <> 0
195 StrCpy $0 $0 "" 1
196 IntOp $3 $3 - 1
197 ${EndIf}
198 IntOp $1 $1 !
199 ${EndIf}
231 roytam 200 StrLen $R8 $4
201 ; ${CharToASCII} $R9 $1
202 ; DetailPrint "x'$0'|'$1'($R9)|'$3'|'$4'[$R8]"
203 ${If} $R8 = 0 ; The end?
227 roytam 204 StrCpy $1 0
205 StrCpy $4 ' '
206 ${EndIf}
207 ${If} $4 == ' '
208 ${AndIf} $1 = 0
209 StrCpy $4 $0 $3
210 StrCpy $1 $4 "" -1
231 roytam 211 ; ${CharToASCII} $R9 $1
212 ; DetailPrint "+'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 213 ${IfThen} $1 == '"' ${|} StrCpy $4 $4 -1 ${|}
214 killspace:
231 roytam 215 ; ${CharToASCII} $R9 $1
216 ; DetailPrint "++'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 217 IntOp $3 $3 + 1
218 StrCpy $0 $0 "" $3
219 StrCpy $1 $0 1
220 StrCpy $3 0
221 StrCmp $1 ' ' killspace
222 Push $0 ; Remaining
231 roytam 223 ; ${CharToASCII} $R9 $1
224 ; DetailPrint "-'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 225 Exch 4
226 Pop $0
227 StrCmp $4 "" 0 moreleft
231 roytam 228 ; ${CharToASCII} $R9 $1
229 ; DetailPrint "*'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 230 Pop $4
231 Pop $3
232 Pop $1
233 Return
234 moreleft:
231 roytam 235 ; ${CharToASCII} $R9 $1
236 ; DetailPrint "/'$0'|'$1'($R9)|'$3'|'$4'"
227 roytam 237 Exch $4
238 Exch 2
239 Pop $1
240 Pop $3
241 Return
242 ${EndIf}
243 IntOp $3 $3 + 1
244 Goto loop
245 FunctionEnd
246  
247  
248 !define fillArgv "!insertmacro fillArgv"
249 !macro fillArgv argline
250 StrCpy $argv0 ""
251 StrCpy $argv1 ""
252 StrCpy $argv2 ""
253 StrCpy $argv3 ""
254 StrCpy $argv4 ""
255 StrCpy $argv5 ""
256 StrCpy $argv6 ""
257 StrCpy $argv7 ""
258 StrCpy $argv8 ""
259 StrCpy $argv9 ""
260 StrCpy $argvc 0
261 Push "${argline}"
262 argloop:
263 Call SplitArg
264 Pop $R9
265 StrCmp $R9 "" argdone
266 ${Switch} $argvc
267 ${Case} 0
268 StrCpy $argv0 $R9
269 ${Break}
270 ${Case} 1
271 StrCpy $argv1 $R9
272 ${Break}
273 ${Case} 2
274 StrCpy $argv2 $R9
275 ${Break}
276 ${Case} 3
277 StrCpy $argv3 $R9
278 ${Break}
279 ${Case} 4
280 StrCpy $argv4 $R9
281 ${Break}
282 ${Case} 5
283 StrCpy $argv5 $R9
284 ${Break}
285 ${Case} 6
286 StrCpy $argv6 $R9
287 ${Break}
288 ${Case} 7
289 StrCpy $argv7 $R9
290 ${Break}
291 ${Case} 8
292 StrCpy $argv8 $R9
293 ${Break}
294 ${Case} 9
295 StrCpy $argv9 $R9
296 ${Break}
297 ${EndSwitch}
298 IntOp $argvc $argvc + 1
299 goto argloop
300 argdone:
301 !macroend
302  
225 roytam 303 !define processLine "!insertmacro processLine"
304 !macro processLine Line
305 Push "${Line}"
306 Call processLine
307 !macroend
308  
309 Function processLine
310 Var /GLOBAL line
311 Var /GLOBAL argv
312 Var /GLOBAL arg0
313 Var /GLOBAL arg1
231 roytam 314 Var /GLOBAL arg0len
225 roytam 315  
316 Pop $0
317 ${StrRep} $line "$0" "$\r" ""
318 ${StrRep} $line "$line" "$\n" ""
319 ${StrRep} $line "$line" "$$0" "$scriptname"
320 ${StrRep} $line "$line" "$$PROGRAMFILES" "$PROGRAMFILES"
321 ${StrRep} $line "$line" "$$PROGRAMFILES32" "$PROGRAMFILES32"
322 ${StrRep} $line "$line" "$$PROGRAMFILES64" "$PROGRAMFILES64"
323 ${StrRep} $line "$line" "$$COMMONFILES" "$COMMONFILES"
324 ${StrRep} $line "$line" "$$COMMONFILES32" "$COMMONFILES32"
325 ${StrRep} $line "$line" "$$COMMONFILES64" "$COMMONFILES64"
326 ${StrRep} $line "$line" "$$DESKTOP" "$DESKTOP"
327 ${StrRep} $line "$line" "$$EXEDIR" "$EXEDIR"
328 ${StrRep} $line "$line" "$$EXEFILE" "$EXEFILE"
329 ${StrRep} $line "$line" "$$EXEDIR" "$EXEDIR"
330 ${StrRep} $line "$line" "$$EXEPATH" "$EXEPATH"
331 ${StrRep} $line "$line" "$$WINDIR" "$WINDIR"
332 ${StrRep} $line "$line" "$$SYSDIR" "$SYSDIR"
333 ${StrRep} $line "$line" "$$TEMP" "$TEMP"
334 ${StrRep} $line "$line" "$$STARTMENU" "$STARTMENU"
335 ${StrRep} $line "$line" "$$SMPROGRAMS" "$SMPROGRAMS"
336 ${StrRep} $line "$line" "$$SMSTARTUP" "$SMSTARTUP"
337 ${StrRep} $line "$line" "$$QUICKLAUNCH" "$QUICKLAUNCH"
338 ${StrRep} $line "$line" "$$DOCUMENTS" "$DOCUMENTS"
339 ${StrRep} $line "$line" "$$SENDTO" "$SENDTO"
340 ${StrRep} $line "$line" "$$RECENT" "$RECENT"
341 ${StrRep} $line "$line" "$$FAVORITES" "$FAVORITES"
342 ${StrRep} $line "$line" "$$MUSIC" "$MUSIC"
343 ${StrRep} $line "$line" "$$PICTURES" "$PICTURES"
344 ${StrRep} $line "$line" "$$VIDEOS" "$VIDEOS"
345 ${StrRep} $line "$line" "$$FONTS" "$FONTS"
346 ${StrRep} $line "$line" "$$TEMPLATES" "$TEMPLATES"
347 ${StrRep} $line "$line" "$$APPDATA" "$APPDATA"
348 ${StrRep} $line "$line" "$$LOCALAPPDATA" "$LOCALAPPDATA"
349 ${StrRep} $line "$line" "$$INTERNET_CACHE" "$INTERNET_CACHE"
350 ${StrRep} $line "$line" "$$COOKIES" "$COOKIES"
351 ${StrRep} $line "$line" "$$HISTORY" "$HISTORY"
352 ${StrRep} $line "$line" "$$PROFILE" "$PROFILE"
353 ${StrRep} $line "$line" "$$ADMINTOOLS" "$ADMINTOOLS"
354 ${StrRep} $line "$line" "$$RESOURCES" "$RESOURCES"
355 ${StrRep} $line "$line" "$$CDBURN_AREA" "$CDBURN_AREA"
356 ${StrRep} $line "$line" "$$RESOURCES_LOCALIZED" "$RESOURCES_LOCALIZED"
230 roytam 357 ${StrRep} $line "$line" "$$retval" "$retval"
358 ${StrRep} $line "$line" "$$var0" "$var0"
359 ${StrRep} $line "$line" "$$var1" "$var1"
360 ${StrRep} $line "$line" "$$var2" "$var2"
361 ${StrRep} $line "$line" "$$var3" "$var3"
362 ${StrRep} $line "$line" "$$var4" "$var4"
363 ${StrRep} $line "$line" "$$var5" "$var5"
364 ${StrRep} $line "$line" "$$var6" "$var6"
365 ${StrRep} $line "$line" "$$var7" "$var7"
366 ${StrRep} $line "$line" "$$var8" "$var8"
367 ${StrRep} $line "$line" "$$var9" "$var9"
225 roytam 368  
369 StrCpy $argv $line
370 ${StrTok} $arg0 $argv " " "0" ""
231 roytam 371 StrLen $arg0len "$arg0 "
372 StrCpy $arg1 "$argv" "" $arg0len
373 ; ${StrRep} $arg1 "$argv" "$arg0 " ""
225 roytam 374  
227 roytam 375 ${fillArgv} $arg1
376  
230 roytam 377 ${If} $argvc > 0
378 ${StrRep} $argv0 "$argv0" "$$empty" ""
379 ${EndIf}
380 ${If} $argvc > 1
381 ${StrRep} $argv1 "$argv1" "$$empty" ""
382 ${EndIf}
383 ${If} $argvc > 2
384 ${StrRep} $argv2 "$argv2" "$$empty" ""
385 ${EndIf}
386 ${If} $argvc > 3
387 ${StrRep} $argv3 "$argv3" "$$empty" ""
388 ${EndIf}
389 ${If} $argvc > 4
390 ${StrRep} $argv4 "$argv4" "$$empty" ""
391 ${EndIf}
392 ${If} $argvc > 5
393 ${StrRep} $argv5 "$argv5" "$$empty" ""
394 ${EndIf}
395 ${If} $argvc > 6
396 ${StrRep} $argv6 "$argv6" "$$empty" ""
397 ${EndIf}
398 ${If} $argvc > 7
399 ${StrRep} $argv7 "$argv7" "$$empty" ""
400 ${EndIf}
401 ${If} $argvc > 8
402 ${StrRep} $argv8 "$argv8" "$$empty" ""
403 ${EndIf}
404 ${If} $argvc > 9
405 ${StrRep} $argv9 "$argv9" "$$empty" ""
406 ${EndIf}
407  
231 roytam 408 StrCmp $line "" done
409 ${If} $parseverbose = 1
410 MessageBox MB_OK "$lineno line = '$line'$\narg0 = '$arg0'$\narg1 = '$arg1'$\n$\nargvc = $argvc$\n$\nargv0 = '$argv0'$\nargv1 = '$argv1'$\nargv2 = '$argv2'$\nargv3 = '$argv3'$\nargv4 = '$argv4'$\nargv5 = '$argv5'$\nargv6 = '$argv6'$\nargv7 = '$argv7'$\nargv8 = '$argv8'$\nargv9 = '$argv9'"
411 ${EndIf}
225 roytam 412  
413 ${Switch} $arg0
414 ${Case} '!wait'
415 ExecWait "$arg1"
416 ${Break}
417 ${Case} '!exec'
418 Exec "$arg1"
419 ${Break}
420 ${Case} '!msgbox'
421 MessageBox MB_OK "$arg1"
422 ${Break}
423 ${Case} '!md'
424 CreateDirectory "$arg1"
425 ${Break}
426 ${Case} '!copy'
230 roytam 427 CopyFiles "$argv0" "$argv1"
225 roytam 428 ${Break}
429 ${Case} '!rd'
231 roytam 430 ${If} $argv0 == '/r'
431 ${If} $argv1 == '/REBOOTOK'
230 roytam 432 RMDir /r /REBOOTOK "$argv2"
225 roytam 433 ${Else}
230 roytam 434 RMDir /r "$argv1"
225 roytam 435 ${EndIf}
231 roytam 436 ${ElseIf} $argv0 == '/REBOOTOK'
437 ${If} $argv1 == '/r'
230 roytam 438 RMDir /r /REBOOTOK "$argv2"
225 roytam 439 ${Else}
230 roytam 440 RMDir /REBOOTOK "$argv1"
225 roytam 441 ${EndIf}
442 ${Else}
230 roytam 443 RMDir "$argv0"
225 roytam 444 ${EndIf}
445 ${Break}
446 ${Case} '!rename'
231 roytam 447 ${If} $argv0 == '/REBOOTOK'
230 roytam 448 Rename /REBOOTOK "$argv1" "$argv2"
225 roytam 449 ${Else}
230 roytam 450 Rename "$argv0" "$argv1"
225 roytam 451 ${EndIf}
452 ${Break}
453 ${Case} '!del'
231 roytam 454 ${If} $argv0 == '/REBOOTOK'
230 roytam 455 Delete /REBOOTOK "$argv1"
225 roytam 456 ${Else}
230 roytam 457 Delete "$argv0"
225 roytam 458 ${EndIf}
459 ${Break}
460 ${Case} '!open'
461 ExecShell "open" "$arg1"
462 ${Break}
463 ${Case} '!regdll'
464 RegDLL "$arg1"
465 ${Break}
466 ${Case} '!unregdll'
467 UnRegDLL "$arg1"
468 ${Break}
230 roytam 469 ${Case} '!plugin'
231 roytam 470 ${Switch} $argvc
471 ${Case} 10
472 Push $argv9
473 Push $argv8
474 Push $argv7
475 Push $argv6
476 Push $argv5
477 Push $argv4
478 Push $argv3
479 Push $argv2
480 CallInstDLL $argv0 $argv1
481 Pop $retval
482 ${Break}
483 ${Case} 9
484 Push $argv8
485 Push $argv7
486 Push $argv6
487 Push $argv5
488 Push $argv4
489 Push $argv3
490 Push $argv2
491 CallInstDLL $argv0 $argv1
492 Pop $retval
493 ${Break}
494 ${Case} 8
495 Push $argv7
496 Push $argv6
497 Push $argv5
498 Push $argv4
499 Push $argv3
500 Push $argv2
501 CallInstDLL $argv0 $argv1
502 Pop $retval
503 ${Break}
504 ${Case} 7
505 Push $argv6
506 Push $argv5
507 Push $argv4
508 Push $argv3
509 Push $argv2
510 CallInstDLL $argv0 $argv1
511 Pop $retval
512 ${Break}
513 ${Case} 6
514 Push $argv5
515 Push $argv4
516 Push $argv3
517 Push $argv2
518 CallInstDLL $argv0 $argv1
519 Pop $retval
520 ${Break}
521 ${Case} 5
522 Push $argv4
523 Push $argv3
524 Push $argv2
525 CallInstDLL $argv0 $argv1
526 Pop $retval
527 ${Break}
528 ${Case} 4
529 Push $argv3
530 Push $argv2
531 CallInstDLL $argv0 $argv1
532 Pop $retval
533 ${Break}
534 ${Case} 3
535 Push $argv2
536 CallInstDLL $argv0 $argv1
537 Pop $retval
538 ${Break}
539 ${Case} 2
540 CallInstDLL $argv0 $argv1
541 Pop $retval
542 ${Break}
543 ${EndSwitch}
230 roytam 544 ${Break}
545 ${Case} '!set'
231 roytam 546 ${Switch} $argv0
547 ${Case} 'var0'
548 StrCpy $var0 $argv1
549 ${Break}
550 ${Case} 'var1'
551 StrCpy $var1 $argv1
552 ${Break}
553 ${Case} 'var2'
554 StrCpy $var2 $argv1
555 ${Break}
556 ${Case} 'var3'
557 StrCpy $var3 $argv1
558 ${Break}
559 ${Case} 'var4'
560 StrCpy $var4 $argv1
561 ${Break}
562 ${Case} 'var5'
563 StrCpy $var5 $argv1
564 ${Break}
565 ${Case} 'var6'
566 StrCpy $var6 $argv1
567 ${Break}
568 ${Case} 'var7'
569 StrCpy $var7 $argv1
570 ${Break}
571 ${Case} 'var8'
572 StrCpy $var8 $argv1
573 ${Break}
574 ${Case} 'var9'
575 StrCpy $var9 $argv1
576 ${Break}
577 ${EndSwitch}
230 roytam 578 ${Break}
579 ${Case} '!intfmt'
580 IntFmt $retval $argv0 $argv1
581 ${Break}
582 ${Case} '!intop'
231 roytam 583 ${Switch} $argv1
584 ${Case} '+'
585 IntOp $retval $argv0 + $argv2
586 ${Break}
587 ${Case} '-'
588 IntOp $retval $argv0 - $argv2
589 ${Break}
590 ${Case} '*'
591 IntOp $retval $argv0 * $argv2
592 ${Break}
593 ${Case} '/'
594 IntOp $retval $argv0 / $argv2
595 ${Break}
596 ${Case} '%'
597 IntOp $retval $argv0 % $argv2
598 ${Break}
599 ${Case} '|'
600 IntOp $retval $argv0 | $argv2
601 ${Break}
602 ${Case} '&'
603 IntOp $retval $argv0 & $argv2
604 ${Break}
605 ${Case} '^'
606 IntOp $retval $argv0 ^ $argv2
607 ${Break}
608 ${Case} '<<'
609 IntOp $retval $argv0 << $argv2
610 ${Break}
611 ${Case} '||'
612 IntOp $retval $argv0 || $argv2
613 ${Break}
614 ${Case} '&&'
615 IntOp $retval $argv0 && $argv2
616 ${Break}
617 ${Case} '~'
618 IntOp $retval $argv0 ~
619 ${Break}
620 ${Case} '!'
621 IntOp $retval $argv0 !
622 ${Break}
623 ${EndSwitch}
230 roytam 624 ${Break}
625 ${Case} '!strrep'
626 ${StrRep} $retval $argv0 $argv1 $argv2
627 ${Break}
628 ${Case} '!strlen'
629 StrLen $retval $argv0
630 ${Break}
631 ${Case} '!strcpy'
231 roytam 632 ${If} $argv1 == ''
633 ${If} $argv2 == ''
230 roytam 634 StrCpy $retval "$argv0"
635 ${Else}
636 StrCpy $retval "$argv0" "" "$argv2"
637 ${EndIf}
638 ${Else}
639 ${If} $argv2 = ''
640 StrCpy $retval "$argv0" "$argv1"
641 ${Else}
642 StrCpy $retval "$argv0" "$argv1" "$argv2"
643 ${EndIf}
644 ${EndIf}
645 ${Break}
333 roytam 646 ${Case} '!shellctx'
647 ${If} $argv0 == 'all'
648 SetShellVarContext all
649 ${Else}
650 SetShellVarContext current
651 ${EndIf}
652 ${Break}
231 roytam 653 ${Case} '!expendenv'
333 roytam 654 ExpandEnvStrings $retval $argv0
231 roytam 655 ${Break}
656 ${Case} '!readenv'
333 roytam 657 ReadEnvStr $retval $argv0
231 roytam 658 ${Break}
333 roytam 659 ; ${Case} '!readregdword'
660 ; ReadRegDWORD $retval $argv0 $argv1 $argv2
661 ; ${Break}
662 ; ${Case} '!readregstr'
663 ; ReadRegStr $retval $argv0 $argv1 $argv2
664 ; ${Break}
665 ; ${Case} '!writeregstr'
666 ; WriteRegStr $argv0 $argv1 $argv2
667 ; ${Break}
231 roytam 668 ${Case} '!readini'
669 ReadINIStr $retval $argv0 $argv1 $argv2
670 ${Break}
333 roytam 671 ${Case} '!writeini'
672 WriteINIStr $argv0 $argv1 $argv2 $argv3
673 ${Break}
674 ${Case} '!mklink'
675 CreateShortcut $argv0 $argv1 $argv2 $argv3
676 ${Break}
230 roytam 677 ${Case} '!findwin'
678 ${If} $argvc = 4
679 ${If} $argv1 = ''
680 FindWindow $retval $argv0 "" $argv2 $argv3
681 ${Else}
682 FindWindow $retval $argv0 $argv1 $argv2 $argv3
683 ${EndIf}
684 ${ElseIf} $argvc = 3
685 ${If} $argv1 = ''
686 FindWindow $retval $argv0 "" $argv2
687 ${Else}
688 FindWindow $retval $argv0 $argv1 $argv2
689 ${EndIf}
690 ${ElseIf} $argvc = 2
691 FindWindow $retval $argv0 $argv1
692 ${Else}
693 FindWindow $retval $argv0
694 ${EndIf}
695 ${Break}
696 ${Case} '!showwin'
697 ShowWindow $argv0 $argv1
698 ${Break}
699 ${Case} '!sendmsg'
700 SendMessage $argv0 $argv1 $argv2 $argv3
701 ${Break}
333 roytam 702 ${Case} '!skip'
703 IntOp $skiplines $argv0 + 0
704 ${Break}
231 roytam 705 ${Case} '!vartoret'
706 ${Switch} $argv0
707 ${Case} 'var0'
708 ${VarToRetval} $var0
709 ${Break}
710 ${Case} 'var1'
711 ${VarToRetval} $var1
712 ${Break}
713 ${Case} 'var2'
714 ${VarToRetval} $var2
715 ${Break}
716 ${Case} 'var3'
717 ${VarToRetval} $var3
718 ${Break}
719 ${Case} 'var4'
720 ${VarToRetval} $var4
721 ${Break}
722 ${Case} 'var5'
723 ${VarToRetval} $var5
724 ${Break}
725 ${Case} 'var6'
726 ${VarToRetval} $var6
727 ${Break}
728 ${Case} 'var7'
729 ${VarToRetval} $var7
730 ${Break}
731 ${Case} 'var8'
732 ${VarToRetval} $var8
733 ${Break}
734 ${Case} 'var9'
735 ${VarToRetval} $var9
736 ${Break}
737 ${EndSwitch}
738 ${Break}
739 ${Case} '!rettovar'
740 ${Switch} $argv0
741 ${Case} 'var0'
742 ${RetvalToVar} $var0
743 ${Break}
744 ${Case} 'var1'
745 ${RetvalToVar} $var1
746 ${Break}
747 ${Case} 'var2'
748 ${RetvalToVar} $var2
749 ${Break}
750 ${Case} 'var3'
751 ${RetvalToVar} $var3
752 ${Break}
753 ${Case} 'var4'
754 ${RetvalToVar} $var4
755 ${Break}
756 ${Case} 'var5'
757 ${RetvalToVar} $var5
758 ${Break}
759 ${Case} 'var6'
760 ${RetvalToVar} $var6
761 ${Break}
762 ${Case} 'var7'
763 ${RetvalToVar} $var7
764 ${Break}
765 ${Case} 'var8'
766 ${RetvalToVar} $var8
767 ${Break}
768 ${Case} 'var9'
769 ${RetvalToVar} $var9
770 ${Break}
771 ${EndSwitch}
772 ${Break}
773 ${Case} '!verbose'
774 ${If} $argv0 == 'on'
775 StrCpy $parseverbose 1
776 ${Else}
777 StrCpy $parseverbose 0
778 ${EndIf}
779 ${Break}
232 roytam 780 !ifndef UTF16Script
781 ${Case} '!utf8'
782 ${If} $argv0 == 'on'
783 StrCpy $utf8script 1
784 ${Else}
785 StrCpy $utf8script 0
786 ${EndIf}
787 ${Break}
788 !endif
225 roytam 789 ${EndSwitch}
790  
231 roytam 791 done:
225 roytam 792 FunctionEnd
793  
794 !define readFile "!insertmacro readFile"
795 !macro readFile File
796 Push "${File}"
797 Call readFile
798 !macroend
799  
800 Function readFile
801 Var /GLOBAL oline
802  
803 Exch $0
804 StrCpy $scriptname $0
805 FileOpen $4 "$scriptname" r
231 roytam 806 !ifdef UTF16Script
807 FileReadUTF16LE $4 $oline
808 !else
225 roytam 809 FileRead $4 $oline
231 roytam 810 !endif
811 StrCpy $lineno 1
333 roytam 812 StrCpy $skiplines 0
225 roytam 813 ${DoUntil} ${Errors}
333 roytam 814 ${If} $skiplines = 0
815 ${processLine} $oline
816 ${Else}
817 IntOp $skiplines $skiplines - 1
818 ${EndIf}
231 roytam 819 IntOp $lineno $lineno + 1
820 !ifdef UTF16Script
821 FileReadUTF16LE $4 $oline
822 !else
232 roytam 823 ${If} $utf8script = 1
824 ${FileReadUTF8} $4 $oline
825 ${Else}
826 FileRead $4 $oline
827 ${EndIf}
231 roytam 828 !endif
225 roytam 829 ${LoopUntil} 1 = 0
830 FileClose $4
831 FunctionEnd
832  
833 Function .onInit
834 SetSilent silent
835 StrCpy $SetupName $EXEFILE -4
836 FunctionEnd
837  
838 Section
839  
840 Var /GLOBAL args
841  
842 StrCpy $args $CMDLINE
231 roytam 843 StrCpy $parseverbose 0
225 roytam 844 ${GetParameters} $args
845  
846 ${If} $args == ""
227 roytam 847 ${If} ${FileExists} `$EXEDIR\$SetupName.txt`
848 ${readFile} "$EXEDIR\$SetupName.txt"
225 roytam 849 ${EndIf}
333 roytam 850 ${Else}
225 roytam 851 ${StrRep} $args "$args" '"' ""
852  
853 ${If} ${FileExists} `$args`
854 ${readFile} "$args"
333 roytam 855 ${Else}
225 roytam 856 ${If} ${FileExists} `$EXEDIR\$args`
857 ${readFile} "$EXEDIR\$args"
229 roytam 858 ${Else}
859 ${processLine} $args
225 roytam 860 ${EndIf}
861 ${EndIf}
862 ${EndIf}
863  
227 roytam 864 ; MessageBox MB_OK "CMDLINE = '$SetupName' '$args'"
225 roytam 865 SectionEnd