Use %systemroot% in my custom scripts


  • Hi All

    I cant figure out how to use %systemroot% rather than C:\ in my custom scripts. Below is code snippet of one of my custom scripts but I'm thinking it would be better practice to have something more dynamic than C:\

    Is there a oEnvironment.Item() I can use? I have looked but cant seem to find anything. I have tried:

    sTargetFolder = "%systemroot%\System32\" But this gives an invalid path error. I know this is something stupidly simple but cant work it out.

    oLogging.CreateEntry sSName & ": PCAP Copy pthreadVC.dll",LogTypeInfo
    sSourceFile = oEnvironment.Item("DeployRoot") & "\Applications\WinPcap\files\SYSDIR\pthreadVC.dll"
    sTargetFolder = "C:\Windows\System32\"
    oFSO.CopyFile sSourceFile, sTargetFolder, True
    If Err<>0 Then 
      oLogging.CreateEntry sSName & ": PCAP Failed to Copy pthreadVC.dll",LogTypeError
      Exit Function
    End If

    Tuesday, July 02, 2013 7:23 AM


  • Try

    sTargetFolder = oShell.ExpandEnvironmentStrings("%systemroot%") & "\System32\"

    • Marked as answer by Tee-Eff Tuesday, July 02, 2013 9:13 AM
    Tuesday, July 02, 2013 8:43 AM

All replies