Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript to replace my current batch logon 1

Status
Not open for further replies.

MikeKhod

IS-IT--Management
Dec 21, 2007
33
US
Can anyone help me to write this in VB script.
I am able to map all drives, but on the H: drive i would like the script to actually create a folder with the users name and map it to the H drive. Also i get an error message if the network drive is mapped already. thanks.
That is the part i cant get to work.
rem Map Network Drives
REM NET USE * /DELETE
NET USE E: /DELETE /YES
REM NET USE F: /DELETE
REM NET USE G: /DELETE
REM NET USE J: /DELETE
rem NET USE E: \\Icverify\request
NET USE E: \\Icvsvr\request
NET USE F: \\W2003svr\Pdcmain
NET USE G: \\W2003svr\Depts
NET USE H: \\W2003svr\Pdcmain\Users\%username%
NET USE I: \\term-srvr-2003\ts3server
NET USE J: \\W2003svr\docs
 
This snippet of code will check to see if a drive called J: exists. If it doesn't exist, it will try to map it.
Code:
If not exists "J:" then
    objNetwork.MapNetworkDrive "J:" , "\\W2003svr\docs"
End If

Or, if you prefer (as I do because it's safer in instances where a drive mapping target changes thanks to a server being renamed or replaced), you can force the script to unmap the drive - if it already exists - before (re-)mapping it:
Code:
If exists "J:" then
    objNetwork.RemoveNetworkDrive "J:", True, True
    objNetwork.MapNetworkDrive "J:" , "\\W2003svr\docs"
Else
    objNetwork.MapNetworkDrive "J:" , "\\W2003svr\docs"
End If

Or
Code:
If exists "J:" then
    objNetwork.RemoveNetworkDrive "J:", True, True
End If
objNetwork.MapNetworkDrive "J:" , "\\W2003svr\docs"

HAPPY NEW YEAR!

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Thank you for your help, and Happy New Year to both of you.
JJ & Mark.
I will try it next year. lol
HAVE A SAFE and SUCCESSFULL 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top