General discussion

Locked

Batch File issue

By ballyb ·
Want to know how to set up this Batch File:

:: DC Login script

@ECHO OFF

:: Delete existing connections
net use c: /delete
net use d: /delete
HALT

:: Map drives
net use c: \\Scanner_Svr\Test1
net use d: \\Test1

EXIT

I want a workstation to map drives to a server (it's C and D drives), at each boot. Obviously, I want to close the connections, at close-down of the workstation.
Have I got the syntax correct? I have the .bat file at the root of C: on the workstation - isthis correct? What do I have to put on the server?

Any asistance would be appreciated....

This conversation is currently closed to new comments.

10 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Batch File issue

by TimTheToolMan In reply to Batch File issue

Hi,

It doesn't really matter where you put the .bat file. I wouldn't put in the root directory, myself - I'd create a Batch directory and store your scripts there.

You dont need anything on the server - apart from appropriate security setups. And those shares to be setup (obviously)!

You need to have the script run at startup. This could be done by moving a shortcut to it to the startup directory of the account you log into on the workstation - this wont map the drives as you boot, however. Only when you log in.

I think you've got the drive mappings wrong. Unless you're not using a local C: drive (or drive for CDrom?) then you'll want to choose different letters.

When you closedown the workstation, obviously the mappings will be dropped.

Note : What you've got specifically maps the Servers drives to the workstation. Not the other way around. The server wont be able to access the workstation's drives. I hope this is what you're after.

Go for it.

Cheers,
Tim.

Collapse -

Batch File issue

by TimTheToolMan In reply to Batch File issue

Oh, two more things. replace :: with rem and halt with exit

Collapse -

Batch File issue

by TimTheToolMan In reply to Batch File issue

Change that... remove the "halt" altogether.

If you're worried about timing, then you can download "sleep.exe" from somewhere on the net and use it to pause a while between the sections.

DOS doesn't have a native sleep.

Collapse -

Batch File issue

by TimTheToolMan In reply to Batch File issue

Well... there you go.... you can leave the :: - they seem to work. A new one for me.

The halt still needs to go, though.

Collapse -

Batch File issue

by ballyb In reply to Batch File issue

helpful. thx

Collapse -

Batch File issue

by Shanghai Sam In reply to Batch File issue

Hi,
I'm not sure which OS you are targetting, but heres a few small points for the NT \ XP family. Firstly, use the cmd extension rather than bat (IE myscript.cmd). Although the functionality is the same in each, with NT \ XP all command shell actions are executed by cmd.exe, if you use the bat extension then command.com is called, but is run virtually via a cmd.exe session (thats why the advanced functionality of the NT shell is available even though you are using the old command interpreter - command.com is only included to allow backwards compatibility with old batch files that may contain functionality which makes calls to the old msdos subsystem) . Using the cmd extension removes the additional 'layer', and has your script executed directly by cmd.exe. The saving is trivial, but it's a good practice to get into. Secondly, with NT \ XP you can add the following to your net use command -

net use d: \\myserver\myshare /PERSISTENT:NO

This means that your mappings will notpersist across logouts \ reboots, otherwise by default (again, with NT \ XP) they will. Also, as this will be a login script, and assuming there are no permanent mapped drives you wish to keep, you can delete any existing mappings with one line -net use * /d /y

Lastly, I take it these are domain logins (IE you called it DC login). If the login account is a domain account, then you can store one copy of the script in the netlogon share of each domain controller, and 'attach' the script tothe user account by adding it to the login script portion of the account details in user manager (or the win2k equivalent 'users and computers'). Use the syntax

\\%logonserver%\netlogon\myloginscript.cmd

Hope at least some of this is relevant....

Collapse -

Batch File issue

by ballyb In reply to Batch File issue

I did use the cmd. v. helpful. thx

Collapse -

Batch File issue

by curlergirl In reply to Batch File issue

Answer #2 seems to be right on point. One additional comment about your drive mappings. You cannot map drive C: on your workstation because presumably you are running your operating system from your local C: drive. Generally speaking you don't want to use the same drive letters for mapped drives as the local drives. If you have a local A:, C: and (i.e., CD-ROM) drive, then start your mapped drives at something higher than that. A standard networking practice for many years has been to start at F:. So, your "net use" commands would be something like:

net use F: \\Scanner_Svr\Test1 /persistent:no
net use G: \\Test1 /persistent:no

Also, I don't remember if this was already said, but you can only use the .cmd extension and the/persistent switch if you have NT/2K/XP workstations - these will not work on Win9x workstations.

Hope this helps!

Collapse -

Batch File issue

by ballyb In reply to Batch File issue
Collapse -

Batch File issue

by ballyb In reply to Batch File issue

This question was closed by the author

Back to Windows Forum
10 total posts (Page 1 of 1)  

Related Discussions

Related Forums