war10ck
war10ck

Reputation: 103

create a bat script to set network directory as a drive(let's say S:) and then calling a bat script within the set directory(somewhere in S)

I run into problems with VM's where i have to manually startup the jobs everytime after the reboot.

I would like a startup bat script to perform the following everytime upon system reboot-

set a network drive as drive s:

(something like what i manually do - "net use s: \network dir name") and then I call a bat script within the s to do the rest( lets say S:\test\test.bat)

How can i create it all as one bat script? and steps on how can I set it as a startup script on system reboot?

Upvotes: 0

Views: 2432

Answers (2)

John Castleman
John Castleman

Reputation: 1561

You say you are wanting a local batch script to do nothing but NET USE a network share as S:\, then run a remote batch script, e.g., S:\test\test.bat, and you want the local batch script to run every time on system startup?

The share mapping part is actually done for you by the NET USE command - type the following once to have S: available as a mapped drive from now on:

NET USE S: \\server\share /PERSISTENT:YES

Mapped drive S: will be available from now on at startup, without running any other batch script: immediately run your S:\test\test.bat.

To run this batch script - or any other executable - at startup, right-click the script/executable, and drag it to Start Menu, All Programs, Startup folder, and drop it (not on the folder, but in the expanded space just below it where other startup programs are): because you right-clicked, Windows Explorer will prompt you to "Copy here", "Move here", or "Create shortcut here" for the file. Select "Create shortcut here" - the file will run at startup from now on.

Upvotes: 0

PA.
PA.

Reputation: 29369

you ask two questions in one.

  1. what is a BAT script?
    in its simplest form, a BAT script is just a text file that contains every instruction you type in the command line as a line in the file. So, you just need to create a text file with notepad, fill it with your commands

    NET USE s: \\server\sharedfolder
    CALL S:\test\test.bat
    

    call it s.bat, place it somewhere in your PATH, and simply invoke it as s in the command line.

  2. how to run such a BAT script at boot?
    the simplest (among many others) solution is to create a shortcut to the s.bat file inside the startup folder.

    a. Click Start, click All Programs, right-click Startup, click Open.

    b. Then locate your s.bat file, ctrl-shift-drag to Startup folder.

Upvotes: 1

Related Questions