Solved

Call another batch file

Posted on 2008-06-20
12
1,751 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 70

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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