Frage

I have a question (obviously hahah)...

This code below finally works for me with the help from stackoverflow.com and various sites...

all I want to do now is to make sure one file doesn't get updated\overwritten ?

How do I achieve this ?

In the source files I have vairous files and "sample.ini" within this is a userid and password section.

when people click my "update Button" in the HTA file I created, I dont want to update that file on their PC's everything is fine to overwrite ?

also...if you see something I could improve please tell me...



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

' -------------------------------------------------------------
War es hilfreich?

Lösung

I'm not sure to understand your problem, but if you don't want to overwrite sample.ini in FinalLoc, I think you should add something like this:

If objFSO.GetFileName(x) <> "sample.ini" Then
    objFSO.GetFile(x).Copy (FinalLoc & "\" & objFSO.GetFileName(x)), True
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top