• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1776
  • Last Modified:

Call another batch file

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
TIO-Solutions
Asked:
TIO-Solutions
1 Solution
 
gavbellCommented:
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
 
TIO-SolutionsAuthor Commented:
Hi there

It is not working. How will it know where the 2nd batch file is located?
0
 
gavbellCommented:
You will need to put the 2nd batch file in the \\logonserver\NETLOGON folder.
"logonserver" being your domain controller.
cheers
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
gavbellCommented:
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
 
TIO-SolutionsAuthor Commented:
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
 
gavbellCommented:

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

call c:\intranet\test.bat


that should do you.
0
 
TIO-SolutionsAuthor Commented:
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
 
rindiCommented:
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
 
TIO-SolutionsAuthor Commented:
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
 
QlemoC++ DeveloperCommented:
There is no need for the copy part. Why not executing from server share directly?
0
 
TIO-SolutionsAuthor Commented:
cant push it through NT
0
 
TIO-SolutionsAuthor Commented:
Got it working thanks
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now