3 Replies Latest reply on May 18, 2009 7:49 AM by zman

    VB Script does not work




      I have created a vb script package as a New Windows Script Host Package to change some registry variables for the webdrive software.


      The task I created has the following properties: Delivery type: Push
      Deliver method: Silent Install from source with reboot if needed


      After starting the task, I get the status as successful [Done->No errors]. But I can not see any changes in the registry. I tried to run the vb script locally, that did not work either. Following is the script. Please let me know the reason.


      ' Begin code for regset1.vbs


      'Change Cache folder to %userprofile%\Application Data\WebDrive\Cache
      'Enable Logging; Set location to %userprofile%\Application Data\WebDrive\Logging
      'Change Backup folder to %userprofile%\Application Data\WebDrive\Backup
      'Certificate Management; Change location to %userprofile%\Application Data\WebDrive\CertStore
      'Hostkey Management; Change location to %userprofile%\Application Data\WebDrive\HostKeys


      Option Explicit


      Dim WSHShell, RegKey, RegValue, Result, UserProfile


      Set WSHShell = CreateObject("WScript.Shell")


      ' get the current users profile
      UserProfile = WSHShell.ExpandEnvironmentStrings("%UserProfile%")
      regKey = "HKEY_CURRENT_USER\Software\South River Technologies\WebDrive\"


      ' set cache and logging for example, copy to set the rest


      WSHShell.RegWrite regkey & "LogFolder", UserProfile & "\Application Data\WebDrive\Logging"
      WSHShell.RegWrite regkey & "BackupFolder", UserProfile & "\Application Data\WebDrive\Backup"
      WSHShell.RegWrite regkey & "SSLCertStoreFolder", UserProfile & "\Application Data\WebDrive\CertStore"
      WSHShell.RegWrite regkey & "SSHHostKeyFolder", UserProfile & "\Application Data\WebDrive\HostKeys"


      ' End code


      Thanks a lot

        • 1. Re: VB Script does not work
          zman Master

          So I suck at vb so I can't check the validity of your code. But it looks like you are trying to change a HKCU setting. If the user logged into the machine at the time of delivery is no a local admin LANDesk will elevate the rights to the local system account.  So I would try running as the Current User's Account. This can be changed on the distribution package - see page 758 of the manual.  The assumption here is that users will have rights to modify the key.

          • 2. Re: VB Script does not work



            If your user has rights then what ZMan recommends is the easiest.  If not, you can still do this, but it's a lot more complicated.


            You will still need to make sure the user is logged on (so we can find that user's SID in the registry, which can be used to find that user's %userprofile% location, which can then be substituted into the rest of your script as your userprofile variable).  Let me know if your users have rights or not, if they don't then I will try and cobble something together that should get you a valid userprofile variable.  I'm not going to do it unless it's actually needed.

            • 3. Re: VB Script does not work
              zman Master

              If you want to convert to Autoitscript then this UDF makes like so much easier. I have used this function to change all HKCU settings for all profiles on a machine. Works extremely well.