Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Windows 2000 Login Script Help

I want to create a windows login script that upon logging into the computer will  1. Map a network drive to a folder on one of our servers, 2. once the drive has been mapped run a file from located on that mapped drive, and 3. once the file has completed running disconnect the network drive so the operator cant access it without knowing the full path.

I know to map the network drive you need to use

"echo off

NET USE Z: \\Server\Path\Folder"

Now as far as running the file once the drive has been mapped and then disconnecting the mapped drive I really dont know how to go about doing it. So I am posting it up for you.

  • 3
  • 2
  • 2
  • +2
1 Solution
mpatrick65Author Commented:
Also is there something that  can be written into the script so that the user wont see the command screen come up?
Pete LongTechnical ConsultantCommented:
>>Also is there something that  can be written into the script so that the user wont see the command screen come up?

you will always see the vlack "Dos" window flick up unless you call it from something else (lie WMI or VB Script)

The first command should be @echo off (" and @ get swapped if your on the wrong input locale so you might want to fix that first ;)

what is the file you want to access????

@echo off
NET USE Z: \\Server\Path\Folder

::do something


Note that removes ALL mapped drives
Pete LongTechnical ConsultantCommented:
if you wnat to keep "some other drives then use

NET USE Z: \\Server\Path\Folder /d
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

mpatrick65Author Commented:
The file that I am trying to access is an executable file located on the mapped server share. That is the ::do something in that code that you wrote up.

It would be similar to running from the command line Z:\program.exe or program.com or program.bat
Chris DentPowerShell DeveloperCommented:

Are you happy with vbscript? If you are this might work for you...

objShell = CreateObject("Wscript.Shell")
objNetwork = CreateObject("Wscript.Network")

objNetwork.MapNetworkDrive "z:", "\\server\path\folder"
objShell.Run "z:\Executable.exe", 0 , 1
objNetwork.RemoveNetworkDrive "z:"

The objShell.Run command has two options after it, the first (0 at the moment) sets the WindowStyle to hidden. The second (1 at the moment) tells the vbscript to wait until the program has finished before continuing.


Is this a program that will run for a little bit like a setup? or software to be used during business hours?
mpatrick65Author Commented:
it will only be ran for a short amount of time like a setup.
One option is to create the share on the server as a hidden share. By appending a $ to the share name. Then instead of having to map a drive you could just point it to \\server01\share$\setup.exe

To create the hidden share, just right click your My Computer and choose manage.
System Tools > Shared Folders > Shares. Right click create new share and append the $ to the sharename.

If you use kixtart here's a script that would do run your app.

$PDC = "\\server01"
use z: /delete /persistent
$X = $PDC + "\share"
use z: $X
shell "z:\setup.exe"

Of if the share was hidden just this.

shell "$pdc\share$\setup.exe"

Do you really need to map a drive?  Why can't you just execute the command using a UNC path, like this:

That way the share is never mapped.  It would also be a good idea to make the share a hidden share by giving it a "$" suffix, as suggested by craylord.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now