#195510 - 2009-08-21 04:48 PM
Windows 7 Drive Mapping
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
I'm currently testing Win7 Pro at work. Obviously the drives are not mapping automatically unless I run a script from my desktop. What do I need to add to the script to map drives on Win7? I tried a "if in Group", no luck, NET USE, no luck. Here is the code that calls logon.bat:
GOSUB MAPDRIVES
;GOSUB WIN_XP
:MAPDRIVES
CLS
Color Y+/n
AT (20,15) "Mapping Department Drives and Checking Norton AntiVirus Status..."
AT (24,79)
;Shell "\\ Servername \VPLOGON\VPLOGON.BAT"
$HOMEDIR=@UserID + "$"
USE H: /DEL
USE H: "\\ Servername \$HOMEDIR"
USE N: /DEL
USE Q: /DEL
USE R: /DEL
USE S: /DEL
USE G: /DEL
USE T: /DEL
USE N: "\\Servername\Dshares\SAP\Documents"
USE Q: "\\Servername \QS9000"
USE R: "\\Servername \DSHARES"
USE S: "\\Servername \GSHARES"
USE G: "\\Servername \APPS"
USE x: "\\Servername \NETWORK_SCANNING"
IF INGROUP ("HEBxWDDrop")
USE Y: /DEL
USE Y: "\\ Servername\loftware$\WDDrop"
ENDIF
:UNKNOWN_OS
GOTO END
ENDIF
:END
Here is the script I manually run from the desktop:
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "R:", "\\ Servername \DShares"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "N:", "\\ Servername \DShares\SAP"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "S:", "\\ Servername \GShares"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "Q:", "\\ Servername \QS9000"
On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "X:", "\\ Servername \Network_Scanning"
On Error Resume Next
Dim strDriveLetter, strRemotePath, strUserName
strDriveLetter = "H:"
strRemotePath = "\\ Servername \"
' Purpose of script to create a network object. (objNetwork)
' Then apply the MapNetworkDrive method. Result H: drive
Set objNetwork = WScript.CreateObject("WScript.Network")
' Here is where we extract the UserName
strUserName = objNetwork.UserName
strUserName = strUserName & "$"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath & strUserName
msgbox ("Drives Have Been Successfully Mapped")
Would It be better if I added a Group for Win7 users and then call the script or what?
Thanks!
Edited by Mart (2009-08-21 04:56 PM) Edit Reason: Please use code tags when posting code.
|
Top
|
|
|
|
#195512 - 2009-08-21 05:08 PM
Re: Windows 7 Drive Mapping
[Re: Allen]
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
Thanks for the info. How would I call the VB Script within logon.bat using the "If in Group"? I had it working with Vista but since lost the code to call it, which I stumbled across it anyways.
I think this would be my best bet.
|
Top
|
|
|
|
#195515 - 2009-08-21 06:48 PM
Re: Windows 7 Drive Mapping
[Re: DStelz]
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
My drive mappings work fine as well in win7 enterprise
|
Top
|
|
|
|
#195517 - 2009-08-21 06:58 PM
Re: Windows 7 Drive Mapping
[Re: Radimus]
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
Can I see some of these scripts?
|
Top
|
|
|
|
#195518 - 2009-08-21 07:11 PM
Re: Windows 7 Drive Mapping
[Re: MasterB]
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
if ingroup("group1") and not ingroup("group2")
MapDrive('e',"\\server\CAU",,,1,1)
MapDrive('g',"\\server\INSP_HQA",,,1,1)
MapDrive('z',"\\server\MISAPPS",,,1,1)
endif
if ingroup("group3")
MapDrive('i',"\\server\insp_hqa",,,1,1)
MapDrive('l',"\\server\cau",,,1,1)
MapDrive('z',"\\server\MISAPPS",,,1,1)
endif
if ingroup('group4')
MapDrive('r','\\server\HCPR',,1,1,1)
endif
;*************************************************************************************************************************
Function MapDrive($DriveLetter, $UNC, optional $Label, optional $Icon, optional $Delete, optional $verbose)
dim $subcmd, $pt, $d, $di, $shell, $text
$d = left($DriveLetter,1)
$di= "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons"
$pt= @producttype
$subcmd = iif($pt = "Windows NT Workstation","subst","net use")
$text = iif($label,$label,' ')
if $delete
shell '%comspec% /c $subcmd $d: /d /y 1>Nul 2>&1'
$nul=deltree("$di\$D")
endif
if not exist('$D:\')
shell '%comspec% /c $subcmd $D: "$UNC" 1>Nul 2>&1'
if $verbose
if not @error
Show(' Connected '+ ucase($driveletter)+ ': to '+ $UNC + ' ( '+ $text + ' )')
sleep 1
else
Show(' FAILED ' + ucase($driveletter)+': Connected to '+ $UNC+ ' ( '+ $text + ' )')
exit 1
endif
endif
else
exit 2
endif
if $pt="Windows XP Professional" or $pt="Windows 2000 Professional"
if $Label
$shell=createobject("shell.application")
$shell.namespace('$D:\').self.name=$Label
endif
if $icon
$=writevalue('$di\$D\DefaultIcon','',$Icon,REG_SZ)
endif
endif
ENDFUNCTION
|
Top
|
|
|
|
#195548 - 2009-08-24 04:17 PM
Re: Windows 7 Drive Mapping
[Re: Richard H.]
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
I have a VBscript that maps the drives. What is the code to execute the VBscript from witin KIX?
|
Top
|
|
|
|
#195550 - 2009-08-24 04:34 PM
Re: Windows 7 Drive Mapping
[Re: Mart]
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
I added it but it's not working. I added to different lines, does it matter which one I use? Is it in the correct order?
GOSUB MAPDRIVES
;GOSUB WIN_XP
:MAPDRIVES
CLS
Color Y+/n
AT (20,15) "Mapping Department Drives and Checking Norton AntiVirus Status..."
AT (24,79)
;Shell "\\HEBADS006\VPLOGON\VPLOGON.BAT"
SHELL "wscript.exe \\servername\SYSVOL\na.autoedir.com\scripts\Sites\HEB\Win_7.vbs"
Shell "wscript Win_7.vbs"
$HOMEDIR=@UserID + "$"
USE H: /DEL
USE H: "\\servername\$HOMEDIR"
USE N: /DEL
USE Q: /DEL
USE R: /DEL
USE S: /DEL
USE G: /DEL
USE T: /DEL
USE N: "\\servername\Dshares\SAP\Documents"
USE Q: "\\servername\QS9000"
USE R: "\\servername\DSHARES"
USE S: "\\servername\GSHARES"
USE G: "\\servername\APPS"
USE x: "\\servername\NETWORK_SCANNING"
IF INGROUP ("HEBxWDDrop")
USE Y: /DEL
USE Y: "\\servername\loftware$\WDDrop"
ENDIF
:UNKNOWN_OS
GOTO END
ENDIF
:END
|
Top
|
|
|
|
#195635 - 2009-08-27 03:12 PM
Re: Windows 7 Drive Mapping
[Re: MasterB]
|
MasterB
Fresh Scripter
Registered: 2009-08-21
Posts: 12
Loc: Kentucky
|
got it figured out.
Added VER | find "6.1" > nul
IF not errorlevel 1 GOTO Win_7
and created a script and then added :win_7
IF Exist \\servername\sysvol\FQDN\scripts\sites\heb\Startup\win_7.vbs START \\servername\sysvol\FQDN\scripts\sites\heb\Startup\win_7.vbs
GOTO END
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
2 registered
(morganw, mole)
and 414 anonymous users online.
|
|
|