General discussion


create bat file to map drive

By RG11 ·
I am looking to create a .bat file that I can place on a users desktop so when the click it,
it will:
1>map a network drive
2>copy files from that network drive to a local drive/folder
3> send the files from the local drive to a network printer

Any help here?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by webjabber In reply to create bat file to map dr ...

It is easy one, you can use dos command net

net help use

you will get help page,

such as mapping a server to a w: drive

net use w: \\server\sharefolder password /USER:domain\username

then use copy command files


A secure path to access your servers

Collapse -

by RG11 In reply to

Poster rated this answer.

Collapse -

by robo_dev In reply to create bat file to map dr ...

vb script is very easy and will do the job without popping dos screens up. Think of vbscript as 'Batch files for windows'

On Error Resume Next
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "F:\TEMP\*.doc" , "C:\TEMP\BAK\" , OverwriteExisting

It is more complicated to send files to a printer, unless they are actual postscript or pcl printer files, then you are just copying the files to the device.

Collapse -

by zaferus In reply to create bat file to map dr ...

Net use batch files are definitely the way to go.

One word of advise is to have a:
net use: <drive letter> /delete

first. This will ensure that the drive letters are used.

Also a /persistent:yes (or no) can keep the drive letter alive - or make sure when the user logs off the drive letter dissapears as well. Both can be important depending on the situation.

Then once the drive letters are done xcopy (or robocopy if you need NTFS perms intact). Lots of switches to look at ones I often use are : /d /h /e /r /c /k /y. (xcopy /? will show switches).

Printing the files can be a little trickier but if you have a printer set as LPTx (x can be defined for ease of use) then you can use the DOS print command to send a file using pipe: ">" to a printer.

Collapse -

by zaferus In reply to

Let me clarify the print - you can copy a file to a printer using the pipe ">" or can use a straight print command:

Print /D:LPTx R:\printme.doc

Collapse -

by RG11 In reply to create bat file to map dr ...

This question was closed by the author

Related Discussions

Related Forums