1 Reply Latest reply on Apr 2, 2012 4:33 AM by RichardA

    Inject Script Without Variable Replacement

    Apprentice

      Is there a good way to inject a script without having it replace variables? (LD9.0 SP1)  I have been trying to inject some VBScripts, but I run into problems.  I try to use environment variables in my scripts as much as possible to make them OS/Language agnostic, but when the script injects, it try's to replace the variables, but I don't have them setup as variables.  Gah!  See below for an example of my vbscript headers:

       

      'Declare scripting objects
      Set oNet = WScript.CreateObject("WScript.Network")
      Set oShell = WScript.CreateObject("WScript.Shell")
      Set oFSO = CreateObject("Scripting.FileSystemObject")
      Set oSpecFolders = oShell.SpecialFolders

       

      'Declare Environment variables
      eAllUsersProfile = oShell.ExpandEnvironmentStrings("%AllUsersProfile%")
      eUserProfile = oShell.ExpandEnvironmentStrings("%UserProfile%")
      eProgramFiles = oShell.ExpandEnvironmentStrings("%ProgramFiles%")
      eWinDir = oShell.ExpandEnvironmentStrings("%WinDir%")

       

      I guess my current plan is to either not use the injecting (I can map a drive, copy the file, run it, delete the file, unmap the drive) or setup variables in LD so that it replaces %AllUsersProfile% with %AllUsersProfile%  (so sad that I have to do that).

        • 1. Re: Inject Script Without Variable Replacement
          Specialist

          I know this is an extremely old question, and I would imagine you've found your solution or workaround by now, but just in case this is still an issue for you, and in case anyone comes here with the same question...

           

          When using environment variables (as opposed to LD provisioning variables) you should be able to wrap them in a double percent signs: %%variable%%.

           

          So your declare section would look like:

          'Declare Environment variables
          eAllUsersProfile = oShell.ExpandEnvironmentStrings("%%AllUsersProfile%%")
          eUserProfile = oShell.ExpandEnvironmentStrings("%%UserProfile%%")
          eProgramFiles = oShell.ExpandEnvironmentStrings("%%ProgramFiles%%")
          eWinDir = oShell.ExpandEnvironmentStrings("%%WinDir%%")

           

          Having said that, consider than user-based environment variables are rarely available during LANDesk tasks as they generally run under the LocalSystem account.

           

          I was fairly convinced I found this information in the LD manual, but looking back now I can't find it, so no idea where I learnt it from!

           

          Message was edited by: Richard Archer to add comment about user variables