1
我想隱藏來自域用戶的共享文件夾的網絡路徑。 (Windows Server 2012中)我發現這個腳本的時候,搜索網絡驅動器標籤:如何在VBScript中獲取%username%?
Option Explicit
Dim objNetwork, strDrive, objShell, objUNC
Dim strRemotePath, strDriveLetter, strNewName
strDriveLetter = "H:"
strRemotePath = "\\servername\sharedfoldername$\"
strNewName = "Save Your Files Here"
'Section to map the network drive
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
'Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName
WScript.Echo "Check : "& strDriveLetter & " for " & strNewName
WScript.Quit
我的網絡路徑將是象下面這樣:
strRemotePath = "\\servername\sharedfoldername1$\%username%"
strRemotePath = "\\servername\sharedfoldername2$\%username%"
strRemotePath = "\\servername\sharedfoldername5$\%username%"
strRemotePath = "\\servername\sharedfoldernameNNN$\%username%"
當我插入%username%
,腳本不運行。
請引導我如何修改該腳本,該腳本將按照我的要求運行。
的[可能的複製我可以拿起vbscript WSH腳本中的環境變量?](http://stackoverflow.com/questions/904739/can-i-pick-up-environment-variables-in-vbscript-wsh-script) – Lankymart
可能重複的[VBScript環境變量](http://stackoverflow.com/q/11620970/692942) – Lankymart