VBScript文件复制文件存在返回错误安装的驱动器

VBScript文件复制文件存在返回错误安装的驱动器,vbscript,installshield,file-copying,mounted-volumes,Vbscript,Installshield,File Copying,Mounted Volumes,我处于使用InstallShield创建的安装包MSI中执行的脚本的上下文中。我执行以下脚本: Set wshShell = CreateObject( "WScript.Shell" ) User = wshShell.ExpandEnvironmentStrings( "%USERNAME%" ) MsgBox "User: " & User ' The parameters are received through MS

我处于使用InstallShield创建的安装包MSI中执行的脚本的上下文中。我执行以下脚本:

Set wshShell = CreateObject( "WScript.Shell" )
User = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )
MsgBox "User: " & User

' The parameters are received through MSI parameters
' msiexec /I MyMSI_x64.msi configFileSrc="Z:\MyFolder\FileToCopy.txt" configFolderDst="c:\temp\"

' Testing parameters
Dim configFileSrc, configFolderDst
configFileSrc = "Z:\MyFolder\FileToCopy.txt"
configFolderDst = "c:\temp\"

' **********************************************************************
' Copy file to destination folder
' **********************************************************************
if(configFileSrc <> "") Then
    call copyFile(configFileSrc, configFolderDst)
End if

' **********************************************************************
' Function to copy file
' **********************************************************************
Sub CopyFile(SourceFile, DestinationFile)

    Set fso = CreateObject("Scripting.FileSystemObject")
    
    If not fso.FileExists(SourceFile) Then
        MsgBox "The file " & SourceFile & " is not found and will therefore not be copied to destination folder.", vbExclamation, "Parameter file not found" 
        Exit Sub
    End If 
 ...
Set wshShell=CreateObject(“WScript.Shell”)
User=wshShell.expandEnvironmentString(“%USERNAME%”)
MsgBox“用户:”&用户
'通过MSI参数接收参数
'msiexec/I MyMSI_x64.msi configFileSrc=“Z:\MyFolder\FileToCopy.txt”configFolderDst=“c:\temp\”
"测试参数",
Dim配置文件RC、配置文件夹DST
configFileSrc=“Z:\MyFolder\FileToCopy.txt”
configFolderDst=“c:\temp\”
' **********************************************************************
'将文件复制到目标文件夹
' **********************************************************************
如果是(configFileSrc“”),则
调用copyFile(configFileSrc、configFolderDst)
如果结束
' **********************************************************************
'用于复制文件的函数
' **********************************************************************
子复制文件(源文件、目标文件)
设置fso=CreateObject(“Scripting.FileSystemObject”)
如果不存在fso.FileExists(SourceFile),则
MsgBox“找不到文件”&SourceFile&“因此将不会复制到目标文件夹。”,VBEquipment,“找不到参数文件”
出口接头
如果结束
...
当从装入的驱动器执行时,FileExists始终返回false。当脚本在本地执行时(替换实际上作为参数提供的configFileSrc),脚本工作正常。 我很确定InstallShield使用的是机器的本地管理员帐户,该帐户可能对安装的驱动器没有权限,但我不知道如何检查。我已尝试显示当前用户strusterName,但该框为空。
有什么想法吗?

映射驱动器是每个用户令牌。管理员有两个令牌。因此,以管理员身份运行意味着它不能作为普通用户访问映射驱动器


使用UNC路径
\\server\sharename\folder\file.ext

您的问题分析可能是正确的。您没有看到用户名的原因是您正在设置变量
User
,而不是
strUserName
。使用
选项Explicit
会使这一点变得明显。这是否回答了您的问题?你好,兰克马特,谢谢。不,它没有解决我的问题。在我的情况下,网络共享已经挂载,访问它会导致问题,尽管路径是正确的。您好,谢谢,错误。事实上,它使我的假设无效。wshShell.ExpandEnvironmentStrings显示的用户与具有访问网络共享相关权限的登录用户相同。事实上,我通过MSI参数接收路径(我更新了主帖子)。我无法控制收到的内容:-S