将文件从脚本目录复制到所有用户的桌面
Copy file from script directory to All Users' desktop
我已经编写了下面的脚本,但是当我 运行 它(使用 PrimalScript 进行故障排除)时,我收到错误 'Permission denied'。
我是此设备的管理员,当我 运行 提升脚本时,我遇到了同样的错误。
这是脚本:
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
我做错了什么?
您必须设置一个进程:
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
虽然我最后的评论显示脚本不起作用,但下面的脚本是 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
谢谢你们。
我已经编写了下面的脚本,但是当我 运行 它(使用 PrimalScript 进行故障排除)时,我收到错误 'Permission denied'。 我是此设备的管理员,当我 运行 提升脚本时,我遇到了同样的错误。
这是脚本:
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
我做错了什么?
您必须设置一个进程:
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
虽然我最后的评论显示脚本不起作用,但下面的脚本是 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
谢谢你们。