How to create a batch script that does the following

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Engerini
Posts: 3
Joined: 13 Apr 2016 23:46

How to create a batch script that does the following

#1 Post by Engerini » 14 Apr 2016 18:08

a. Checks if x: drive is already mapped to \\<servername>\<foldername>. If not pr if x: drive is mapped to something else, it removes that and maps it.
b. Runs a Autoreg.exe program located in the mapped x: drive
c. Runs a Views.exe and opens a pg_menu.nfo

The batch will be saved on a shared drive.

I am new to batch script and all I could write was given below;

Code: Select all

echo off
rem delete existing mapped drives
net use * /d /Y

rem map new network drive
net use Z: \\bwswh03\PNGInLaw

echo drives mapped.

Kindly assist with this. Thanks so much in advance.

Engerini
Posts: 3
Joined: 13 Apr 2016 23:46

Re: How to create a batch script that does the following

#2 Post by Engerini » 16 Apr 2016 22:01

I wrote the following script and it ran but didn't open up the pg_menu.nfo page. please help.

Code: Select all

@echo off
net use Z: /D > null
net use Z: \\bwswh03\PNGInLaw
Z:autoreg
z: views pg_menu.nfo

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to create a batch script that does the following

#3 Post by foxidrive » 17 Apr 2016 14:08

This is a guess as to what you need - the dir command will show you the files in the mapped drive, and the pause will usually let you see any error messages on the screen.

Code: Select all

@echo off
net use Z: /D > null
net use Z: \\bwswh03\PNGInLaw
Z:\autoreg
views z:\pg_menu.nfo
dir z:\
pause

Engerini
Posts: 3
Joined: 13 Apr 2016 23:46

Re: How to create a batch script that does the following

#4 Post by Engerini » 17 Apr 2016 17:01

Thanks mate, this works perfectly fine. You are a genious! :lol:

Post Reply