Solved

Call another batch file

Posted on 2008-06-20
12
1,705 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 68

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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now