'* MP, 02.04.2014 Pri kopiranju na virtualno postajo sedaj pogleda kako se mapa imenuje (%UserProfile%), prej pa explicitno na C:\Documents and Settings\... '* MP, 07.07.2013 Če v isti mapi obstoja NaNetSub.vbs ali NaNetSub.bat, izvede tisto, ki obstoja in izstopi iz NaNet.vbs. '* MP, 30.05.2011 '* MM, 02.02.2011 '* Iz PotBaze prebere Pot programa. '* Nato pogleda iz katere mape je bil ta VbScript pognan, od tam vzame program in ga skopira na Pot v ustrezno mapo. '* Če je potrebno, potem kopira tudi na "C:\Documents and Settings\" + lsUserName + "\Finesa.Xp\....", oziroma po novem %UserProfile%\Finesa.Xp\.... Dim objShell, WSHShell Dim lsFilePath, lsOdKod, oFso, oTextFilein, lsReadLine, lsSelfZip, lsDir Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set oFso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Shell.Application") '* Če obstoja NaNetSub.vbs, jo izvedede in izstopi Set WSHShell = CreateObject("WScript.Shell") lsFilePath=left(WScript.ScriptFullName,Len(WScript.ScriptFullName) - len(WScript.ScriptName)) & "NaNetSub.vbs" IF oFso.FileExists(lsFilePath) = True Then WSHShell.Run("wscript """ & lsFilePath & """") WScript.Quit End if '* Če obstoja NaNetSub.bat, jo izvedede in izstopi lsFilePath=left(WScript.ScriptFullName,Len(WScript.ScriptFullName) - len(WScript.ScriptName)) & "NaNetSub.bat" IF oFso.FileExists(lsFilePath) = True Then WSHShell.Run("""" & lsFilePath & """") WScript.Quit End if On Error Resume Next Set objExplorer = Wscript.CreateObject("InternetExplorer.Application") If Err.Number = 0 Then objExplorer.Navigate "about:blank" objExplorer.Toolbar = 0 objExplorer.StatusBar = 0 objExplorer.Width = 510 objExplorer.Height = 100 objExplorer.Left = 400 objExplorer.Top = 200 Do While (objExplorer.Busy) Wscript.Sleep 200 Loop objExplorer.Visible = 1 objExplorer.Document.Title = "Posodabljanje programa na mrežni disk" objExplorer.Document.Body.InnerHTML = "Program se posodablja. Počakajte trenutek ..." End If On Error GoTo 0 lsFilePath=left(WScript.ScriptFullName,Len(WScript.ScriptFullName) - len(WScript.ScriptName)) & "PotBaze.txt" IF oFso.FileExists(lsFilePath) = False Then lsFilePath="C:\Finesa.Xp\PotBaze.txt" End if Set oTextFileIn = oFso.OpenTextFile(lsFilepath, ForReading) lsReadLine = oTextFilein.ReadLine lsReadLine=RTrim(Mid(lsReadLine,InStr(1,lsReadLine,"#",vbTextCompare )+1)) IF Right(lsReadLine,1)="\" Then lsReadLine=Left(lsReadLine, Len(lsReadLine)-1) End IF lsOdKod=WScript.ScriptFullName IF Ucase(lsReadLine)=Ucase(Left(lsOdKod,Len(lsReadLine))) Then '* Kopiranje ni potrebno. MsgBox "Program je posodobljen na lokalni disk.",,"Posodobitev programa z www.finesa.si" On Error Resume Next objExplorer.Quit WScript.Quit End IF IF (oFso.FolderExists(lsReadLine)) = False Then MsgBox "Pri kopiranju programa na mrežni disk je prišlo do napake, Mapa " & lsReadLine & " ne obstoja." WScript.Quit End If '* Pridobim UserName prijavljenega uporabnika Dim strDomain ,lsUserName, objNet Set objNet = WScript.CreateObject("WScript.Network") lsUserName = objNet.UserName '* Najprej dobim kaj je potrebno kopirati lsDir=RTrim(Mid(lsOdKod,1,len(lsOdKod)-10)) While InStr(1,lsDir,"\",vbTextCompare ) > 0 lsDir=RTrim(Mid(lsdir,InStr(1,lsDir,"\",vbTextCompare )+1,len(lsDir))) Wend '* Kopiranje IF AliObstajaKateraDatoteka("C:\Finesa.Xp\" + lsDir + "\", "Ade")=False Then MsgBox "Nepravilen klic programa!" WScript.Quit End If NarediMapoCeJeNi lsReadLine + "\" + lsDir + "\" NarediMapoCeJeNi "C:\Finesa.Xp\" + lsDir + "\ScriptSQL" '* Kopiranje ADE Dim objFolder Dim Files, File Set Files = oFso.GetFolder("C:\Finesa.Xp\" + lsDir).Files ParentFolder = lsReadLine + "\" + lsDir + "\" If Files.Count <> 0 Then For Each File In Files IF UCase(ofso.GetExtensionName(File)) = "ADE" Then Set objFolder = objShell.NameSpace(ParentFolder) objFolder.CopyHere "C:\Finesa.Xp\" + lsDir + "\" + File.Name, &H10& End If Next End If '* Kopiranje Chm IF AliObstajaKateraDatoteka("C:\Finesa.Xp\" + lsDir + "\", "Chm") = True Then oFso.CopyFile "C:\Finesa.Xp\" + lsDir + "\*.Chm", lsReadLine + "\" + lsDir + "\", True Else MsgBox "Manjkajoča datoteka: " + "C:\Finesa.Xp\" + lsDir + "\*.Chm Pokličite vzdrževalca programske opreme Finesa!" End If '* Kopiranje ScriptSQL Set objFolder = objShell.NameSpace(ParentFolder) objFolder.CopyHere "C:\Finesa.Xp\" + lsDir + "\ScriptSQL", &H10& '* Preveri in po potrebi kopira še na Virtualno postajo Set objShell = CreateObject("WScript.Shell") lsUserProfile=objShell.ExpandEnvironmentStrings("%UserProfile%") IF AliObstajaKateraDatoteka(lsUserProfile + "\Finesa.Xp\" + lsDir + "\", "Ade") = True Then oFso.CopyFile "C:\Finesa.Xp\" + lsDir + "\*.Ade", lsUserProfile + "\Finesa.Xp\" + lsDir + "\", True IF AliObstajaKateraDatoteka("C:\Finesa.Xp\" + lsDir + "\", "Chm") = True Then oFso.CopyFile "C:\Finesa.Xp\" + lsDir + "\*.Chm", lsUserProfile + "\Finesa.Xp\" + lsDir + "\", True End If oFso.CopyFolder "C:\Finesa.Xp\" + lsDir + "\ScriptSQL", lsUserProfile + "\Finesa.Xp\" + lsDir + "\", True End IF '* Po starem explicitno na C:\Documents and Settings\ 'IF AliObstajaKateraDatoteka("C:\Documents and Settings\" + lsUserName + "\Finesa.Xp\" + lsDir + "\", "Ade") = True Then ' oFso.CopyFile "C:\Finesa.Xp\" + lsDir + "\*.Ade", "C:\Documents and Settings\" + lsUserName + "\Finesa.Xp\" + lsDir + "\", True ' IF AliObstajaKateraDatoteka("C:\Finesa.Xp\" + lsDir + "\", "Chm") = True Then ' oFso.CopyFile "C:\Finesa.Xp\" + lsDir + "\*.Chm", "C:\Documents and Settings\" + lsUserName + "\Finesa.Xp\" + lsDir + "\", True ' End If ' oFso.CopyFolder "C:\Finesa.Xp\" + lsDir + "\ScriptSQL", "C:\Documents and Settings\" + lsUserName + "\Finesa.Xp\" + lsDir + "\", True 'End IF '* Zaprem WinZipSelfExtract, če se ni že sam '* Ni potrebno 'sComputer = "." 'Set oWmi = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2") 'Set colProcessList = oWmi.ExecQuery ("Select * from Win32_Process Where Name = '" & sProcessName & "'") 'For Each oProcess in colProcessList ' oProcess.Terminate() 'Next On Error Resume Next objExplorer.Quit MsgBox "Program je posodobljen.",,"Posodobitev programa z www.finesa.si" Function NarediMapoCeJeNi(argMapa) IF oFso.FolderExists( argMapa) = False Then oFso.CreateFolder(argMapa) End If End Function Function AliObstajaKateraDatoteka(argMapa, argKoncnica) Dim Files, File AliObstajaKateraDatoteka=False IF oFso.FolderExists( argMapa) = True Then Set Files = oFso.GetFolder(argMapa).Files If Files.Count <> 0 Then For Each File In Files IF UCase(ofso.GetExtensionName(File)) = UCase(argKoncnica) Then AliObstajaKateraDatoteka=True Exit Function End If Next End If End If End Function