0

我已经编写了下面的脚本,但是当我运行它(使用 PrimalScript 进行故障排除)时,我收到错误“权限被拒绝”。我是这个设备的管理员,当我运行提升的脚本时我得到了同样的错误。

这是脚本:

Dim WshShell, strCurDir, File, strDesktop

Set WshShell = CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("AllUsersDesktop")
Set ofso = CreateObject("Scripting.FileSystemObject")
strPath = ofso.GetParentFolderName(WScript.ScriptFullName)
File = "pwsafe.psafe3"
strCurDir = ofso.BuildPath(strPath, File)

ofso.CopyFile strCurDir , strDesktop , OverwriteExisting

我究竟做错了什么?

4

2 回答 2

0

您必须设置一个流程:

Dim ofso, oshell, oproc, strDesktop, overwrite
Set ofso = CreateObject("Scripting.FileSystemObject")
Set oshell = CreateObject("WScript.Shell")
Set oproc  = oshell.Environment("Process")
strDesktop = oproc.Item("UserProfile") & "\Desktop\"
overwrite = True
ofso.CopyFile "pwsafe.psafe3" , strDesktop , overwrite
于 2015-09-21T14:19:38.740 回答
0

虽然我的最后一条评论显示了不起作用的脚本,但下面的脚本是 Sergio 和 Lankymart 工作的组合。想提他们两个,因为他们值得称赞。这是工作脚本,我希望其他人可以使用它。

Dim ofso, oshell, oproc, strDesktop, overwrite
Set ofso = CreateObject("Scripting.FileSystemObject")
Set oshell = CreateObject("WScript.Shell")
Set oproc  = oshell.Environment("Process")
strDesktop = oproc.Item("ALLUSERSPROFILE") & "\Desktop\"
overwrite = True
ofso.CopyFile "pwsafe.psafe3" , strDesktop , overwrite

谢谢你俩。

于 2015-09-21T20:50:08.560 回答