Jump to content

laptopC

Member
  • Posts

    3
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    Finland

Everything posted by laptopC

  1. Thanks again from answers. Here is some backgroud. The application is locally installed, and it is currently installed from setup.exe which install it to c:\program files\appdirectory\. It is also available in MSI package which installs it to c:\program files\appdirectory2\. I have a script that checks computers registry and if the string for MSI install is not found the uninstall is started and new version from MSI is installed. Something like this: reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{the-string-goes-here} if errorlevel==1 goto setup if errorlevel==0 goto end :setup Uninstall script here msiexec /i \\server\share\application.msi -qn \\server\share\script.vbs :end exit So this uninstalls previous version, installs new and modifies the shortcuts from common desktop (script.vbs). script.vbs will be done from those what you posted. This already does what I originally wanted it to do, but lets say that some computers are missing shortcuts from common desktop and users have created their own to their personal desktops. In that case I guess that I should also create logon script to check those. Would it work if I just replace Const UDtop = &H10& Set oApp = CreateObject("Shell.Application") Set oShell = CreateObject("WScript.Shell") Set oFso = CreateObject("Scripting.FilesystemObject") ' String in the target property to search for sTargetStrOld = "C:\Program Files\OldProgDir\executable.exe" ' New string to set sTargetStrNew = "C:\Program Files\NewProgDir\executable.exe" 'Check for registry key sTargetRegKey ="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{key-here}" If RegKeyExists(sTargetRegKey) then Set oDir = oApp.Namespace(UDtop) Set oDItem = oDir.Self sLocn = oDItem.Path ChkLnk(sLocn) Sub ChkLnk (sFolder) Set oFolder = oFso.GetFolder(sFolder) Set oFiles = oFolder.Files For Each oFile In oFiles If LCase(oFso.GetExtensionName(oFile)) = "lnk" Then Set oLnk = oShell.CreateShortcut(oFile) If LCase(oLnk.TargetPath) = LCase(sTargetStrOld) Then oLnk.TargetPath = sTargetStrNew oLnk.Save End If End If Next End Sub Else WScript.Quit Function RegKeyExists(ByVal sRegKey) ' Returns True or False based on the existence of a registry key. ' This part is a compliment from Torgeir Bakken. Dim sDescription RegKeyExists = True sRegKey = Trim (sRegKey) If Not Right(sRegKey, 1) = "\" Then sRegKey = sRegKey & "\" End If On Error Resume Next oShell.RegRead "HKEYNotAKey\" sDescription = Replace(Err.Description, "HKEYNotAKey\", "") Err.Clear oShell.RegRead sRegKey RegKeyExists = sDescription <> Replace(Err.Description, sRegKey, "") On Error Goto 0 End Function End If</Edit>
  2. Thanks. It worked with VBScript. The code looked something like this: Set oWS = WScript.CreateObject("WScript.Shell") sLinkFile = "C:\documents and settings\all users\työpöytä\link.lnk" Set oLink = oWS.CreateShortcut(sLinkFile) oldpath=oLink.TargetPath newpath="C:\program files\program\executable.exe" oLink.WorkingDirectory="C:\program files\program" oLink.TargetPath=newpath oLink.Save The original script failed to copy links to directory with letters ä and ö. Tested this with temp directory.
  3. Hello. Is it possible to copy shortcut from network share to all users desktop with computer startup script? I have tried these: (Finnish version of Windows is in use so työpöytä = desktop) copy /y \\server\share\shortcut.lnk "c:\documents and settings\all users\työpöytä\" copy /y \\server\share\shortcut.lnk "c:\documents and settings\all users\työpöytä\shortcut.lnk" ..but it wont work. Is there a problem with ä and ö? Or is it even possible to do this with system account? I would like to do this is because I want to upgrade one application that has been previously installed from setup.exe and the new version of this app would be installed from .MSI. The problem is that users would have shortcuts in their desktops pointing nowhere because the new version installs elsewhere than previous.
×
×
  • Create New...