Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-15-2021, 12:21 PM
dsp00k dsp00k is offline
Registered User
 
Join Date: Apr 2019
Posts: 5
Odd error trying to get a directory.

Hi.

I am having a strange issue. When I use the following extremely basic code snippet, the return sometimes works properly, and other times I get a completely different outcome.

... platformType is passed to the function

Code:
Dim p, ppfile, ppfso, ppcmd, ppShell, ppPath
              
                ' Create the full path to the command file
                Set ppShell = CreateObject("Wscript.Shell")

                ppPath = ppShell.CurrentDirectory
                ppfile = ppPath & "\" & platformType & ".pp"

                ' Message box for Debugging Only
                msgbox ppfile

                'Open the command file
                Set ppfso = CreateObject("Scripting.FileSystemObject")
                Set p = ppfso.OpenTextFile(ppfile, ForReading)

...
It is supposed to return the path of the running script so I can call a file that is located in the same directory as the script. i.e.
c:\users\donnie\scripts and then construct the full filename which is supposed to be something like "c:\users\donnie\scripts\9k.pp"


Sometimes it works properly, and most other times I get "c:\windows\system32\9k.pp" as the returned path instead, which of course leads to a File not Found.


Thanks,
Donnie

Last edited by cboyack; 04-15-2021 at 02:40 PM. Reason: Please use [CODE] and [/CODE] tags to denote areas of code
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 09:41 PM.