Board logo

标题: 映射网络磁盘的启动脚本, ComputerName 变量有问题??? [打印本页]

作者: beyoungse     时间: 2007-9-3 15:27    标题: 映射网络磁盘的启动脚本, ComputerName 变量有问题???

V BS 是在windows 用户登录前运行的程序。但是我指定了启动脚本,没有运行!??



启动脚本作用:
我描述不清楚,我就案例子说一下

数据服务器计算机名 server
共享名 A001$、A002$、A003$ ……A040$

客户机计算机名是 001、002、003……040

访问用户名称  A001、A002、A003……A040

共享密码        A001、A002、A003……A040


最后再把映射的盘名称改一下为:DATA



#OK.VBS
On error resume next

Set objNet = CreateObject("Wscript.Network")
strCompName = objnet.ComputerName
strNewName = "data"
strDriveLetter = "d:"

' Section to map the network drive
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "d:","\\server\A" & strCompName & "$",,"A" & strCompName, "A" & strCompName

' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName


内容祥见:
http://www.cn-dos.net/forum/viewthread.php?tid=33234&fpage=1

[ Last edited by beyoungse on 2007-9-3 at 06:09 PM ]
作者: beyoungse     时间: 2007-9-3 15:42
在调试中是完全正常的。
可是在windows 启动脚本中没有出现网络磁盘D:
作者: slore     时间: 2007-9-3 15:57
去掉On error resume next看看有没有错误……
启动前执行是执行了,关键是是不是要启动以后才有效。
作者: beyoungse     时间: 2007-9-3 16:36

作者: beyoungse     时间: 2007-9-3 16:37
提示没有共享路径
作者: beyoungse     时间: 2007-9-3 16:39

作者: beyoungse     时间: 2007-9-3 17:02
可以用IP 做启动脚本的变量不?

客户机IP是:
192.168.10.2……192.168.10.41

请各位老大支招
作者: beyoungse     时间: 2007-9-3 17:40
顶上去,看一下
作者: slore     时间: 2007-9-3 19:27
你进去了运行是不是就可以了?
没有登陆的话是不是就找不到网络路径?

如果这样的话,脚本没有问题,是没有登陆访问不到的……
作者: luowei14     时间: 2007-9-3 19:57
....试试BAT映射
作者: beyoungse     时间: 2007-9-4 11:01
VBS怎么判断网络初始化完成后(一直等待计算机名可用),再进行挂网络盘...
作者: slore     时间: 2007-9-4 13:19
登陆后启动不行麽?
作者: beyoungse     时间: 2007-9-4 14:03
不行的,我漫游了用户配置文件
作者: slore     时间: 2007-9-4 14:12
sleep挂起一段时间吧
作者: beyoungse     时间: 2007-9-4 14:57
挂起30秒,运行也报错




下面就是第10行

objNetwork.MapNetworkDrive "d:","\\server\A" & strCompName & "$",,"A" & strCompName, "A" & strCompName
作者: slore     时间: 2007-9-4 15:54
没登陆进去貌似不能访问那些吧?