Windows 2000 Login Script Help

Posted on 2005-04-22
Last Modified: 2010-04-14
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.

Question by:mpatrick65

    Author Comment

    Also is there something that  can be written into the script so that the user wont see the command screen come up?
    LVL 57

    Expert Comment

    by:Pete Long
    >>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
    LVL 57

    Expert Comment

    by:Pete Long
    if you wnat to keep "some other drives then use

    NET USE Z: \\Server\Path\Folder /d

    Author Comment

    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 or program.bat
    LVL 70

    Expert Comment

    by:Chris Dent

    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.


    LVL 16

    Expert Comment

    Is this a program that will run for a little bit like a setup? or software to be used during business hours?

    Author Comment

    it will only be ran for a short amount of time like a setup.
    LVL 16

    Expert Comment

    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"
    LVL 12

    Accepted Solution


    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now