vbscript - map drive to remember - Techist - Tech Forum

Go Back   Techist - Tech Forum > Computer Software > Microsoft Windows and Software
Click Here to Login
Closed Thread
 
Thread Tools Display Modes
 
Old 11-20-2006, 05:14 PM   #1 (permalink)
True Techie
 
Join Date: Feb 2006
Posts: 228
Send a message via ICQ to selina Send a message via Yahoo to selina
Question vbscript - map drive to remember

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?
__________________

selina is offline  
Old 11-20-2006, 05:22 PM   #2 (permalink)
Repeat Offender
 
superdave1984's Avatar
 
Join Date: Aug 2006
Location: South Fulton, TN
Posts: 1,980
Default

Does the script run at login? If so, they should remap each time.
__________________

__________________
Change the world. Of one person. Today.

If your equation requires either a complex combination of variables to get the desired result OR you can't seem to get the result regardless of the variables....it ain't your variables, it's your constant.
superdave1984 is offline  
Old 11-20-2006, 05:24 PM   #3 (permalink)
Master Techie
 
Join Date: Oct 2003
Posts: 2,258
Default

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.
Inaris is offline  
Old 11-20-2006, 05:47 PM   #4 (permalink)
True Techie
 
Join Date: Feb 2006
Posts: 228
Send a message via ICQ to selina Send a message via Yahoo to selina
Default

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.
selina is offline  
Old 11-20-2006, 06:59 PM   #5 (permalink)
Chillin Techie
 
Join Date: Nov 2004
Location: USA
Posts: 11,861
Default

how do I make a batch file for this?
__________________
The Ultimate Hard Drive Utility PowerMax 4.23. (It now has the ability to clean a Boot Sector virus on the quick erase option.)
The best browser Netscape 8
Have you accidently delete something? Look here (trial. the better one) and here(free)
EricB is offline  
Old 11-20-2006, 08:08 PM   #6 (permalink)
It's all just 1s and 0s
 
office politics's Avatar
 
Join Date: Jan 2004
Location: in the lab
Posts: 6,555
Send a message via MSN to office politics
Default

use wshshell.run to execute net use command.

http://www.devguru.org/technologies/...shell_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}]
office politics is offline  
Old 11-20-2006, 08:42 PM   #7 (permalink)
Techie Beyond Description
 
Osiris's Avatar
 
Join Date: Jan 2005
Location: Kentucky
Posts: 36,817
Send a message via ICQ to Osiris Send a message via AIM to Osiris Send a message via MSN to Osiris Send a message via Yahoo to Osiris
Default

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
__________________
Osiris is offline  
Old 11-21-2006, 01:52 PM   #8 (permalink)
Master Techie
 
Join Date: Oct 2003
Posts: 2,258
Default

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
Inaris is offline  
Old 11-21-2006, 03:52 PM   #9 (permalink)
True Techie
 
Join Date: Feb 2006
Posts: 228
Send a message via ICQ to selina Send a message via Yahoo to selina
Default

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?
selina is offline  
Old 11-21-2006, 05:36 PM   #10 (permalink)
Master Techie
 
Join Date: Oct 2003
Posts: 2,258
Default

Quote:
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.
__________________

Inaris is offline  
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -5. The time now is 08:42 AM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.