script path

Hi there,

Can anyone who is good in scripting tell me what I need to write so when runing my script it looks for files near it, something like script_path & your file. I cant manage to do that. Basically what I need is to run reg file from vbscript but cannot manage to do that coz don`t know how. What I can do is to put hard coded path and it workes but that is lame.

1 Comment   [ + ] Show comment
  • Not sure I understand your question, have you tried using wildcards? - areiner 7 years ago

Answers (4)

Posted by: jagadeish 7 years ago
Red Belt

Option Explicit
Dim objShell, objFSO, CurrentDirectory
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = objFSO.GetParentFolderName(WScript.ScriptFullName)

objShell.Run "RegEdit.exe /S " & Chr(34) & CurrentDirectory & "\MyRegistry.reg" & Chr(34)

Set objShell = Nothing
Set objFSO = Nothing

Posted by: SMal.tmcc 7 years ago
Red Belt

if you click on the little yellow qeustion mark by Policies or Job rules you will see these

  • what you want to do is is upload the vbs file as a dependency and call it
    like "on success - launch a program"
    and launch c:\windows\system32\cscript.exe with parameters $(KACE_DEPENDENCY_DIR)\MYSCRIPT.VBS - SMal.tmcc 7 years ago
Posted by: lanselots 7 years ago
Fifth Degree Brown Belt

Looks like I really mesed up this question, will try different way. I have reg file which need to be runed from vbs because vbs installs application and in the end I want that the same vbs runs reg file which is in the same location where vbscript is, so I don`t know how to write correct path so vbs see that reg file is in the same location. Hope that was more explained.

  • In this case you'll need to hard code the path that the script runs from. On a Windows 7 system it would be c:\ProgramData\Dell\KACE\scripts\<scriptid>\ where <scriptid> is the ID of the script you are running. - chucksteel 7 years ago
    • I am trying to run this one 'MBSASetup-x64-EN.msi' as a dependency but can't seem to get the path correct in the Task itself...
      Error creating process: C:\ProgramData\Dell\KACE\kbots_cache\packages\kbots\182\MBSASetup-x64-EN.msi /i: (193)
      Error Code: 193

      Any ideas? - bnerison 6 years ago
  • try using .\file.reg
    .\ means current directory - SMal.tmcc 7 years ago
Posted by: lanselots 7 years ago
Fifth Degree Brown Belt

Thanks for the response, but now I have a problem runing it on Windows 7 x64 because the registry entries are populated in 32 bit registry not 64, any idea how to make runing script so it runs the same reg file but in 64, so it puts all information in correct location.


Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ