Welcome !
         

 how to get working drive and directory?

Author Message
LawfulEvil

  • Total Posts : 10
  • Scores: 0
  • Reward points : 0
  • Joined: 7/25/2004
  • Location:
  • Status: offline
how to get working drive and directory? Sunday, August 15, 2004 5:47 PM (permalink)
0
Dear all,

I need to write a script to read the script's directory information and i face some problem.

if i put my script under C:\temp

How can i get the working drive (return c:\) ?
How can i get the working directory? (return temp or c:\temp)?

 
#1
    LawfulEvil

    • Total Posts : 10
    • Scores: 0
    • Reward points : 0
    • Joined: 7/25/2004
    • Location:
    • Status: offline
    Re: how to get working drive and directory? Sunday, August 15, 2004 8:56 PM (permalink)
    0
    ops.

    I get it solve


    Set fso = CreateObject("Scripting.FileSystemObject")
    filepath = fso.GetAbsolutePathName("")
     
    #2
      mbouchard

      • Total Posts : 2186
      • Scores: 37
      • Reward points : 0
      • Joined: 5/15/2003
      • Location: USA
      • Status: offline
      Re: how to get working drive and directory? Monday, August 16, 2004 1:36 AM (permalink)
      0
      Here are a couple other ways to get the info you are looking for.

      Set fso = CreateObject("Scripting.FileSystemObject")
      GetAbsolutePath = fso.GetAbsolutePathName("Wscript.ScriptName") 'Returns path and file name of file specified
      GetTheParent = fso.GetParentFolderName("Wscript.ScriptName")'Returns the parentfolder of the Path/File specified
      GetTheBase = fso.GetBaseName("Wscript.ScriptName")'Returns the file name minus file extension
      GetTheScriptFullName = WScript.ScriptFullName'Returns path of the script being called.
      GetTheScriptName = Wscript.ScriptName'Returns the name of the script

      msgbox "Using AbsolutePath: " & GetAbsolutePath & vbcr _
      & "Using GetParentFolderName: " & GetTheParent & vbcr _
      & "Using GetBaseName: " & GetTheBase & vbcr _
      & "Using ScriptFullName: " & GetTheScriptFullName & vbcr _
      & "Using ScriptName: " & GetTheScriptName
       
      #3
        LawfulEvil

        • Total Posts : 10
        • Scores: 0
        • Reward points : 0
        • Joined: 7/25/2004
        • Location:
        • Status: offline
        Re: how to get working drive and directory? Tuesday, August 17, 2004 7:07 PM (permalink)
        0
        thanks mbouchard.

        your detail reply is very useful for me.
        Thank you
         
        #4
          flapclock

          • Total Posts : 1
          • Scores: 0
          • Reward points : 0
          • Joined: 9/5/2004
          • Location:
          • Status: offline
          Re: how to get working drive and directory? Sunday, September 05, 2004 8:45 PM (permalink)
          0
          mbouchard's answer is actually very incorrect. LawfulEvil, use this instead:

          Set fso = CreateObject("Scripting.FileSystemObject")
          GetDriveName = fso.getDriveName(WScript.ScriptFullName)'Returns the drive
          GetParentFolderName = fso.GetParentFolderName(WScript.ScriptFullName)'Returns the parentfolder of the Path/File specified
          GetBaseName = fso.GetBaseName(WScript.ScriptName)'Returns the file name minus file extension
          GetScriptFullName = WScript.ScriptFullName 'Returns path and file name of file specified
          GetScriptName = Wscript.ScriptName'Returns the name of the script

          MsgBox "Using GetDriveName: " & GetDriveName & vbCr _
          & "Using GetParentFolderName: " & GetParentFolderName & vbCr _
          & "Using GetBaseName: " & GetBaseName & vbCr _
          & "Using GetFullName: " & GetScriptFullName & vbCr _
          & "Using ScriptName: " & GetScriptName

          I removed "GetAbsolutePath" because it's exactly the same as getting the full name of the script, and added getdrivename, as you wanted to know the drive your script was executing in.
           
          #5
            mbouchard

            • Total Posts : 2186
            • Scores: 37
            • Reward points : 0
            • Joined: 5/15/2003
            • Location: USA
            • Status: offline
            Re: how to get working drive and directory? Tuesday, September 07, 2004 1:40 AM (permalink)
            0
            Flaplock, What is "very incorrect" about my post? Just wondering.
             
            #6
              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 3 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2017 ASPPlayground.NET Forum Version 3.9