URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Infrastructure Services
  HTML https://infrastructureservices.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Application Packaging
       *****************************************************
       #Post#: 22--------------------------------------------------
       Resolving Hard coded path in Vbscript
       By: JeH Date: October 21, 2019, 8:19 am
       ---------------------------------------------------------
       i was trying my hands-on packaging Vlc application during source
       validation i found out that
       once the shortcut is launched its keeping some data (a folder
       named vlc) in appdata location
       thus, we need to create active set up so that the same data gets
       reflected in all the user
       profile
       To achieve this i kept the same folder named vlc in the package
       and a vbscript which actually
       copy this folder named vlc and place it in every user profile.
       I triggered this VBscript by putting it into a active setup
       Below is the Vb script::
       Option Explicit
       Dim fso,objapp,oshell,user
       'Line 4 and 5 is to make the script run in admin mode
       Set objapp = createobject("Shell.application")
       objapp.ShellExecute "cmd.exe",,,"runas",0
       Set fso = CreateObject("Scripting.FileSystemObject")
       'line 8 and 9 is to access the environment variable
       Set oShell = CreateObject( "WScript.Shell" )
       user=oShell.ExpandEnvironmentStrings("%appdata%") & "\vlc"
       If fso.FileExists("C:\Program Files
       (x86)\VideoLAN\VLC\file-check.vbs") Then
       fso.CopyFolder "C:\Program Files (x86)\VideoLAN\VLC\vlc",user
       Else
       wscript.echo "Vb_script dosent exist"
       End If
       my question over here is in the FileExists("C:\Program Files
       (x86)\VideoLAN\VLC\file-check.vbs") and
       CopyFolder "C:\Program Files (x86)\VideoLAN\VLC\vlc" i have
       given a hard coded path so if the user changes the
       install dir location then this script wont function.
       Is there any way by which i can make the above two path
       change(or automatically pick the path) if the user change the
       install dir
       #Post#: 23--------------------------------------------------
       Re: Resolving Hard coded path in Vbscript
       By: uday Date: October 21, 2019, 2:10 pm
       ---------------------------------------------------------
       C:\Program files = %ProgramFiles%
       C:\Program files (x86) = %Programfiles(x86)%
       [font=courier]Set oShell = CreateObject("WScript.Shell")
       variable1 =
       oShell.ExpandEnvironmentStrings("%ProgramFiles%")[/font]
       *****************************************************