setrclip.blogg.se

Vbs get file path
Vbs get file path











StrNewFile = strNewFile & strNextLine & vbCrLf Set objTextFile = objFSO.OpenTextFile(profile_path & “\AppData\LocalLow\Sun\Java\Deployment\deployment.properties”, ForReading) Set objFSO = CreateObject(“Scripting.FileSystemObject”) Profile_path = objShell.ExpandEnvironmentStrings(“%USERPROFILE%”)

vbs get file path

Set objShell = CreateObject(“WScript.Shell”) I was trying to use the profile path with another directory to change the size of the java cache setting and this is how I got it to work: To use the variable in a command use the “&” sign.

  • Replace(WScript.ScriptFullName,WScript.ScriptName,””).
  • ‘This gives the current shell directory rather than the script’s directory – use with caution!
  • set wshell = createobject(”wscript.shell”).
  • OShell.CurrentDirectory = oFSO.GetParentFolderName(Wscript.ScriptFullName)

    vbs get file path

    Set ofso = CreateObject(”Scripting.FileSystemObject”) Set oShell = CreateObject(”WScript.Shell”).Too easy, but really useful.Įdit: This post has been very popular and there have been a few alternatives provided, here are some of them: Pretty simple one to follow, it grabs the script name (with path), finds the length, grabs the script name by itself, finds the length, subtracts and you’re left with the path. currentDirectory = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))

    vbs get file path

    This is great for referencing other files. Since my post on VBScript command line parameters is by far the most popular, here’s some useful script we use to get the current directory your script is running from.













    Vbs get file path