Solved

Call another batch file

Posted on 2008-06-20
12
1,724 Views
Last Modified: 2008-06-20
Good day

How do I call a batch file from within another batch file? So when I run the 1st batch file it should automatically run the one I'm calling.
0
Comment
Question by:TIO-Solutions
12 Comments
 
LVL 1

Expert Comment

by:gavbell
ID: 21829099
Hi All you need to do is enter

call %logonserver%\netlogon\batchfile.bat

batchfile being the batch file that you want to run 2nd

Cheers

Make sure its in the netlogon folder also matey.
0
 

Author Comment

by:TIO-Solutions
ID: 21829114
Hi there

It is not working. How will it know where the 2nd batch file is located?
0
 
LVL 1

Expert Comment

by:gavbell
ID: 21829139
You will need to put the 2nd batch file in the \\logonserver\NETLOGON folder.
"logonserver" being your domain controller.
cheers
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 1

Expert Comment

by:gavbell
ID: 21829153
it you want the batch file to run from another location type

call \\server\share\batchfile.bat

Cheers

I just put them all in the netlogon folder so you dont need to tell it where it is and also if you have more than 1 domain controller it will replicate the batch files automatically so there is a copy of each one on all DC'S.
0
 

Author Comment

by:TIO-Solutions
ID: 21829165
If it's on my local machine, do I just change the location? This is what I' got:

copy c:\intranet\test.bat c:\intranet2
copy c:\intranet\test.reg c:\intranet2

now I need to run the test.bat file
0
 
LVL 1

Expert Comment

by:gavbell
ID: 21829181

copy c:\intranet\test.bat c:\intranet2
copy c:\intranet\test.reg c:\intranet2

call c:\intranet\test.bat


that should do you.
0
 

Author Comment

by:TIO-Solutions
ID: 21829201
the problem is I want to copy the test.bat and test.reg files from a central point to some users onto their local pc's. Which means, I need to call the file I've copied and run it. By example I should call c:\intranet2\test.bat which is not working
0
 
LVL 88

Expert Comment

by:rindi
ID: 21829236
There is no mention of domains or servers in the Question. So just use the full path to the 2nd batch file after the call command, similar to the examples above.

If your 2nd batch file is file2.bat, and it is located in C:\Batch, use:

call C:\Batch\file2.bat

If the batch file is on a filesystem that supports long filenames, and it is located in C:\Batch Files, then you can try using:

call "C:\Batch Files\file2.bat"

or

call C:\BatchF~1\file2.bat

The command above is used if your DOS version can only cope with the 8.3 filenames that were supported on old filesystems. In that case you can only use 8 characters in your directory name of your batch file.
0
 

Author Comment

by:TIO-Solutions
ID: 21829326
Not working.
We dont have AD so now we need to copy a batch file that will make changes to your registry. So I want to dump the two files on the server and then copy it to the users machine through a batch file that will then also automatically run the batch file that has been copied.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 21829727
There is no need for the copy part. Why not executing from server share directly?
0
 

Author Comment

by:TIO-Solutions
ID: 21830547
cant push it through NT
0
 

Author Comment

by:TIO-Solutions
ID: 21831017
Got it working thanks
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question