Board logo

标题: [问题求助] VBS往C盘复制文件提示权限不够 [打印本页]

作者: iverking    时间: 2022-12-30 10:04     标题: VBS往C盘复制文件提示权限不够

往C盘路径:C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp
复制文件

源码:
Const OverwriteExisting = True
fso.CopyFile pathdesktop &"\JY.url" , "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp", OverwriteExisting
我需要把VBS文件做成自解压的文件 让用户运行,请教怎么能做到提升权限?
作者: Batcher    时间: 2022-12-30 11:19

回复 1# iverking


Const OverwriteExisting = True
FSO.CopyFile FolderDesktop & "\JY.url", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\", OverwriteExisting
作者: Batcher    时间: 2022-12-30 12:17

回复 1# iverking
  1. If Not WScript.Arguments.Named.Exists("RunAsAdmin") Then
  2.   CreateObject("Shell.Application").ShellExecute WScript.FullName, """" & WScript.ScriptFullName & """ /RunAsAdmin", "", "runas", 1
  3.   WScript.Quit
  4. End If
  5. Set Shell = CreateObject("WScript.Shell")
  6. FolderDesktop = Shell.SpecialFolders("Desktop")
  7. Set FSO = CreateObject("Scripting.FileSystemObject")
  8. Const OverwriteExisting = True
  9. FSO.CopyFile FolderDesktop & "\JY.url", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\", OverwriteExisting
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2