|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
16 楼』:
Quote: | Originally posted by wudixin96 at 2007-9-2 17:30:
Set objComputer = CreateObject("Shell.LocalMachine")
Wscript.Echo "Computer name: " & objComputer.MachineName |
|
会提示 Computer name: XXX (还要点一下确定)
我不能实现 这行批处理所要的结果(NET USE D: \\SERVER\%COMPUTERNAME% %COMPUTERNAME% /USER:%COMPUTERNAME%),能不能帮我写一个VBS
|
|
2007-9-2 17:44 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
17 楼』:
在windows 中文站得到如下代码(加上自己套) 不能正常运行
On error resume next
Set objNet = CreateObject("Wscript.Network")
strCompName = objnet.ComputerName
Set objNetwork = CreateObject("Wscript.Network")
strNewName = "data"
' 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
|
|
2007-9-2 21:00 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
18 楼』:
"d:","\\server\A"strCompName"$","A"strCompName"","A"strCompName""
你看看……
字符串相当混乱!
|
|
2007-9-2 21:02 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
19 楼』:
老大,帮帮我看看下面代码的第十三行
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
|
|
2007-9-2 21:46 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
20 楼』:
objNetwork.MapNetworkDrive "d:","\\server\A" & strCompName & "$","A" & strCompName, "A" & strCompName,
第3个参数好像不对吧?最后为什么还有,?
第13行……看来是最后一行。
如果你用"D"字符串看看还出错不?不的话应该对的。
|
|
2007-9-2 23:41 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
21 楼』:
' #test.vbs
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
' #完
|
|
2007-9-3 10:52 |
|
|
wudixin96
银牌会员
积分 1928
发帖 931
注册 2007-1-6
状态 离线
|
『第
22 楼』:
object.MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
看清楚这行,如果想要用户名和密码,而不需要UpdateProfile的话,也要把位置给让出来的。
strLocalName, strRemoteName,, strUser, strPassword
中间有两逗号
|
|
2007-9-3 11:00 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
23 楼』:
只设置strLocalName, strRemoteName就可以啦
|
|
2007-9-3 11:12 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
|
2007-9-3 11:16 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
25 楼』:
是可以啦,谢谢 22F ,但是不能改变此盘的名称
|
|
2007-9-3 11:24 |
|
|
wudixin96
银牌会员
积分 1928
发帖 931
注册 2007-1-6
状态 离线
|
『第
26 楼』:
谢谢slore了,人老了,眼睛都不好使了
[ Last edited by wudixin96 on 2007-9-3 at 11:55 AM ]
|
|
2007-9-3 11:40 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
27 楼』:
Quote: | Originally posted by wudixin96 at 2007-9-3 11:40:
strDriveLetter
此变量从何而来?? |
|
他前面定义了……貌似是d
|
|
2007-9-3 11:48 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
28 楼』:
问题解决
strDriveLetter = "d:"
|
|
2007-9-3 12:13 |
|
|
beyoungse
中级用户
积分 253
发帖 112
注册 2005-12-20
状态 离线
|
『第
29 楼』:
#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
|
|
2007-9-3 12:25 |
|