Tech Support Guy banner
Status
Not open for further replies.
1 - 2 of 2 Posts

·
Retired Trusted Advisor
Joined
·
9,247 Posts
Discussion Starter · #1 ·
I have a batch file that is supposed to map a drive letter, copies a file to a share, run it, unmap the drive, then repeat for a second computer. The batch file looks like this:

net use Z: \\computername1\c$ password /user:domain\usernamer /persistent:no
copy somefile.bat Z: /Y
Z:\somefile.bat
net use Z: /delete
net use Z: \\computername2\c$ password /user:domain\usernamer /persistent:no
copy somefile.bat Z: /Y
Z:\somefile.bat
net use Z: /delete

My problem is that the batch file carries out the commands for the first computer only, then the window closes with the drive letter still mapped to the first computer share. If I re-open the window and type net use Z: /delete then the drive is removed.

Why doesn't it work? Possibly something to do with running a batch file within another batch file?

Edit: DUH! As soon as I type the last line above, the lightbulb turned on! Remembered the CALL command. :confused:
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top