vbscript - map drive to remember

Status
Not open for further replies.

selina

In Runtime
Messages
228
i've written a vbscipt to map network drives and it works fine except for one thing. the mapped drives are removed after reboot. why is this? and how can i fix this so that the mapped dirves are remembered?
 
how are you mapping the driver? what is the code you are using?

there is a persistant swich that can be applied from the "Net use" process, but we need to know how you are doing it, to help you.
 
either i run it at login or after logged in, it still removes the mapped drives when i reboot it. i'm using :
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath

even though i know that i can run the script at each logon, i prefer not to. i don't think it'l matter that much but i'd rahter not run unnecessary script if i can avoid.

i'm not using batch file to do this.
 
use wshshell.run to execute net use command.

http://www.devguru.org/technologies/wsh/quickref/wshshell_Run.html

Set WshShell = WScript.CreateObject("WScript.Shell")
intReturn = WshShell.Run("notepad " & WScript.ScriptFullName, 1, TRUE)
WshShell.Popup "Notepad is now closed."

Code:
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]
 
Here is mine that runs when the user logs on

@echo off
Echo ArvinMeritor Logon Script

VER | find "NT" > nul
IF not errorlevel 1 GOTO Win_NT

VER | find "2000" > nul
IF not errorlevel 1 GOTO Win_NT

VER | find "XP" > nul
IF not errorlevel 1 GOTO Win_NT

VER | find "98" > nul
IF not errorlevel 1 GOTO Win_9X

VER | find "95" > nul
IF not errorlevel 1 GOTO Win_9X

VER | find "5.2.3790" > nul
IF not errorlevel 1 GOTO Win_NT


GOTO unknown_os

:win_NT
IF EXIST %WINDIR%\KIX32.EXE CALL %WINDIR%\KIX32.EXE %logonserver%\netlogon\KIXTART.KIX && GOTO END
IF NOT EXIST %WINDIR%\KIX32.EXE COPY %logonserver%\netlogon\KIX\K*.* %windir%\
CALL %WINDIR%\KIX32.EXE %logonserver%\netlogon\KIXTART.KIX
GOTO END


:win_9X
IF EXIST %WINDIR%\KIX32.EXE CALL %WINDIR%\KIX32.EXE %0\..\KIXTART.KIX
IF NOT EXIST %WINDIR%\KIX32.EXE CALL %0\..\KIX\KIX32.EXE %0\..\KIXTART.KIX

:unknown_os
:end
 
to map a drive at logon, you can do one of the following... this is based on 1 of 2 things. You are using AD to manage your accounts, or you are doing this only from the machine.

There are several paths to mess with, but the easiest one is to simply run a .bat file in the startup folder of all users. the batch would look like this.
Code:
REM Only mapping a drive
net use z: \\server\share /persistant:yes
REM you can add  /user:username password if you need to map it under anothers credentials.

We use a Perl script and a custom module to manage it all for us, but it's all the same process. Ours are done each time you logon. reason for that is mobility. it your mobile, you don't want to waste the machines cpu cycles trying to reconnect to a network resouce that isn't available.

the other thing, is you can specify a login script to run from within AD. This allows it to be managed centrally, and makes it very easy
 
i'm using vbscript to do this only because i'm not too familar with .bat files. i'm managing this using AD and want to standardize it from there. we're in the middle of installing new servers to the branch offices and that's why i need to remap the network drives for each users. it would be nice if i don't have to run the script each logon. is there any way that the mapped drives are remembered at the next logon?
 
it would be nice if i don't have to run the script each logon. is there any way that the mapped drives are remembered at the next logon?

why? the logon script should only take 10 seconds to most. what is your hesitation with running them every time you logon?

You can use the persistant switch to do that, but like I said before, it's not a good method to use, when you need to be able to have this run all the time anyway.
 
Status
Not open for further replies.
Back
Top Bottom