我有一个问题(显然是哈哈)......
以下代码最终在stackoverflow.com和各种网站的帮助下适用于我......
我现在要做的就是确保一个文件没有得到更新\覆盖?
我如何实现这一目标?
在源文件中,我有文件和“sample.ini”,这是一个用户ID和密码部分。
当人们点击我创建的HTA文件中的“更新按钮”时,我不想在他们的PC上更新该文件,一切都可以覆盖吗?
同样......如果你看到我可以提高的东西,请告诉我......
Set objFSO = CreateObject("Scripting.FileSystemObject")
' -------------------------------------------------------------
If Not objFSO.FolderExists("H:\Pavles Program") Then
Set FinalLoc = objFSO.CreateFolder("H:\Pavles Program")
End If
' -------------------------------------------------------------
SourceServer = "\\VBScript_Source\"
FinalLoc = "H:\Pavles Program\"
For Each x In objFSO.GetFolder(SourceServer).Files
If Not objFSO.FileExists(FinalLoc & "\" & objFSO.GetFileName(x)) Then
objFSO.GetFile(x).Copy (FinalLoc & "\" & objFSO.GetFileName(x)), True
Wscript.Echo "Files Copied"
Else
Wscript.Echo "Files Exist"
End If
Next
set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set objShell = WScript.CreateObject("WScript.Shell")
Set lnk = objShell.CreateShortcut(strDesktop & "\Pavs Shortcuts.lnk")
lnk.TargetPath = "H:\Pavles Program\NewMenu.hta"
lnk.Arguments = ""
lnk.Description = "Created Shortcut with VBScript By Pavle"
lnk.HotKey = "CTRL+SHIFT+F"
lnk.WindowStyle = "1"
lnk.WorkingDirectory = "H:\Pavles Program\"
lnk.IconLocation = Windir & "\System32\shell32.dll,43"
lnk.Save
Set lnk = objShell.CreateShortcut(strDesktop & "\READ ME.lnk")
lnk.TargetPath = "H:\Pavles Program\Read Me.txt"
lnk.Arguments = ""
lnk.Description = "Created Shortcut with VBScript By Pavle"
lnk.WindowStyle = "1"
lnk.WorkingDirectory = "H:\Pavles Program\"
lnk.IconLocation = Windir & "\System32\shell32.dll,40"
lnk.Save
' -------------------------------------------------------------
' -------------------------------------------------------------
MsgBox ("Installed Updates"), vbSystemModal
' -------------------------------------------------------------
答案 0 :(得分:1)
我不确定你是否理解你的问题,但是如果你不想在FinalLoc中覆盖sample.ini,我想你应该添加这样的东西:
If objFSO.GetFileName(x) <> "sample.ini" Then
objFSO.GetFile(x).Copy (FinalLoc & "\" & objFSO.GetFileName(x)), True