#24345 - 2002-07-03 10:46 PM
Too many batch files being called at once?
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Hi All, it's me again.
I have a batch file, script1.bat that calls other bats which in turn calls scripts. It seems simple enough:
@echo off echo. echo Synchronizing Desktop Time with Domain echo. net time \\dc1-sd /set /yes >nul
%0\..\kix32.exe %0\..\macro.bat
%0\..\inv.bat
%0\..\makedir.bat
%0\..\netbackup.bat
Macro.bat maps drives, etc....it works fine. inv.bat calls inv.kix, which does an inventory of the PC. That works also, but I will include the bat:
@ECHO ON :: Script.bat Must be designated as logon Script in user manager. :: This logic is necessary for Win95 and Win98 clients. :: Last edited by Charles Cannon 4/19/02
@ECHO OFF
:START IF EXIST "x:\nodomain.script" goto END IF "%OS%"=="Windows_NT" GOTO WINNT
:WIN9X SET KIXDIR=%WINDIR%\KIX SET KIXSCRIPT=\\dc1-sd\netlogon\inv.kix SET KIXVER=KIX362
:COPY IF NOT EXIST %KIXDIR%\NUL MKDIR %KIXDIR% IF EXIST %KIXDIR%\%KIXVER% GOTO KIXCOPIED COPY %0\..\KIX32.EXE %KIXDIR% /Y >NUL COPY %0\..\KX16.DLL %KIXDIR% /Y >NUL COPY %0\..\KX32.DLL %KIXDIR% /Y >NUL COPY %0\..\KX95.DLL %KIXDIR% /Y >NUL :: ECHO. >%KIXDIR%\%KIXVER%
:KIXCOPIED IF NOT EXIST %KIXDIR%\KIX32.EXE COPY %0\..\KIX32.EXE %KIXDIR% >NUL IF NOT EXIST %KIXDIR%\KX16.DLL COPY %0\..\KX16.DLL %KIXDIR% >NUL IF NOT EXIST %KIXDIR%\KX32.DLL COPY %0\..\KX32.DLL %KIXDIR% >NUL IF NOT EXIST %KIXDIR%\KX95.DLL COPY %0\..\KX95.DLL %KIXDIR% >NUL
IF NOT EXIST %0 GOTO NOEXT %KIXDIR%\KIX32.EXE %0 $kixscript="%KIXDIR%\KIX32.EXE %KIXSCRIPT%" GOTO LOGON
:LOGON \\dc1-sd\netlogon\KIX32.EXE %kixscript% GOTO END
:NOEXT %KIXDIR%\KIX32.EXE %0.BAT $kixscript="%KIXDIR%\KIX32.EXE %KIXSCRIPT%" GOTO END
:WINNT %logonserver%\netlogon\KIX32.EXE %logonserver%\netlogon\inv.kix
pause
:END
Where I'm having the problem is with the other two, makedir and netbackup.bat.
The makedir is exactly the same as above, with the exception of changing inv.kix to makedir.kix, and the same with netbackup.bat.
I'm sure you want to know why I'm so repetitive, but I don't know any better. The makedir.kix is: If EXIST ("c:\foldername") GOTO END ELSE shell '%comspec% /c md "c:\foldername"' ENDIF :END The netbackup.kix installs netbackup: IF EXIST ("c:\foldername\~netbackup.txt") GOTO END ELSE shell "%COMSPEC% /e:2048 /c \\server\nbp\setup.exe" copy "\\server\nbp\~netbackup.txt" "c:\foldername" ENDIF :END These scripts work independently, but not in script1.bat
Sorry this is so long, but I know that you all like as much detail as possible, even if it is painful.
Thx in advance for your expertise.
BTW, I will be out for a while but will check email.
|
|
Top
|
|
|
|
#24346 - 2002-07-04 03:24 AM
Re: Too many batch files being called at once?
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Your script1.bat works like it is design. Important for you is to know:
- COM/EXE doesn't using CALL statement. during execution BAT file will wait
for completion. - BAT requires a CALL statement or not.
- required CALL statement means: your script1.bat will wait for the completion of calling BATch file. - CALL statement not using means: your script1.bat will start calling BATch file and will NOT return to your next statement of script1.bat after completion.
So your script1.bat may look like:
code:
@echo off echo. echo Synchronizing Desktop Time with Domain echo. net time \\dc1-sd /set /yes >nul
%0\..\kix32.exe %0\..\macro.kix call %0\..\inv.bat call %0\..\makedir.bat call %0\..\netbackup.bat @echo off
greetings. btw: we advise you to use macro.kix instead of macro.bat, when it is a kixtart scripts. Yet, it is very confusing.
|
|
Top
|
|
|
|
#24347 - 2002-07-08 11:26 PM
Re: Too many batch files being called at once?
|
WeakLink
Fresh Scripter
Registered: 2002-03-06
Posts: 37
Loc: San Diego
|
Thanks for clarifying MCA.....you always help out in a pinch
|
|
Top
|
|
|
|
#24348 - 2002-07-08 11:29 PM
Re: Too many batch files being called at once?
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
you are always welcome. greetings.
|
|
Top
|
|
|
|
#24349 - 2002-07-08 11:33 PM
Re: Too many batch files being called at once?
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Under NT, we see: quote:
C:\>call /? Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
batch-parameters Specifies any command-line information required by the batch program.
If Command Extensions are enabled CALL changes as follows:
CALL command now accepts labels as the target of the CALL. The syntax is:
CALL :label arguments
A new batch file context is created with the specified arguments and control is passed to the statement after the label specified. You must "exit" twice by reaching the end of the batch script file twice. The first time you read the end, control will return to just after the CALL statement. The second time will exit the batch script. Type GOTO /? for a description of the GOTO :EOF extension that will allow you to "return" from a batch script.
In addition, expansion of batch script argument references (%0, %1, etc.) have been changed as follows:
%* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...)
Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax:
%~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter only %~p1 - expands %1 to a path only %~n1 - expands %1 to a file name only %~x1 - expands %1 to a file extension only %~s1 - changes the meaning of n and x options to reference the short name instead %~$PATH:1 - searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string
The modifiers can be combined to get compound results:
%~dp1 - expands %1 to a drive letter and path only %~nx1 - expands %1 to a file name and extension only %~dp$PATH:1 - searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one found.
In the above examples %1 and PATH can be replaced by other valid values
If we look at Windows XP, we see the following: quote:
C:\Documents and Settings\kdyer>call /? Calls one batch program from another.
CALL [drive:][path]filename [batch-parameters]
batch-parameters Specifies any command-line information required by the batch program.
If Command Extensions are enabled CALL changes as follows:
CALL command now accepts labels as the target of the CALL. The syntax is:
CALL :label arguments
A new batch file context is created with the specified arguments and control is passed to the statement after the label specified. You must "exit" twice by reaching the end of the batch script file twice. The first time you read the end, control will return to just after the CALL statement. The second time will exit the batch script. Type GOTO /? for a description of the GOTO :EOF extension that will allow you to "return" from a batch script.
In addition, expansion of batch script argument references (%0, %1, etc.) have been changed as follows:
%* in a batch script refers to all the arguments (e.g. %1 %2 %3 %4 %5 ...)
Substitution of batch parameters (%n) has been enhanced. You can now use the following optional syntax:
%~1 - expands %1 removing any surrounding quotes (") %~f1 - expands %1 to a fully qualified path name %~d1 - expands %1 to a drive letter only %~p1 - expands %1 to a path only %~n1 - expands %1 to a file name only %~x1 - expands %1 to a file extension only %~s1 - expanded path contains short names only %~a1 - expands %1 to file attributes %~t1 - expands %1 to date/time of file %~z1 - expands %1 to size of file %~$PATH:1 - searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string
The modifiers can be combined to get compound results:
%~dp1 - expands %1 to a drive letter and path only %~nx1 - expands %1 to a file name and extension only %~dp$PATH:1 - searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one found. %~ftza1 - expands %1 to a DIR like output line
In the above examples %1 and PATH can be replaced by other valid values. The %~ syntax is terminated by a valid argument number. The %~ modifiers may not be used with %*
HTH,
Kent
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 641 anonymous users online.
|
|
|