ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Relative path in batch

    Scheduled Pinned Locked Moved IT Discussion
    10 Posts 5 Posters 307 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gjacobseG
      gjacobse
      last edited by

      I may be possible to do this via Powershell, and at some point that may be. The point.

      But right now, I am trying to prevent people from causing issues going forward with renaming the source folder.

      This simple script - Windows Batch file - dos the following;

      -Copy shortcut to /users/public/desktop
      -Calls install of adobe Reader XI (compatibility issue with newer)
      -Calls install of two additional applications.

      Since I created it, the path to it has been changed twice... Is there a way to set a variable that grabs the path -

      ETA:
      I many have answered my own question. Generally the folder is access via Explorer, not CMD. As such, I dont think it can grab the path to the file.

      WrCombsW 1 Reply Last reply Reply Quote 1
      • JaredBuschJ
        JaredBusch
        last edited by JaredBusch

        %publicdesktop% or something like that.

        gjacobseG 1 Reply Last reply Reply Quote 1
        • WrCombsW
          WrCombs @gjacobse
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • F
            flaxking
            last edited by

            You want the path to the folder that the script is in? %~dp0

            gjacobseG 1 Reply Last reply Reply Quote 0
            • gjacobseG
              gjacobse @JaredBusch
              last edited by

              @JaredBusch said in Relative path in batch:

              %publicdesktop% or something like that.

              THat will work for the public desktop - indeed.

              1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse @flaxking
                last edited by

                @flaxking said in Relative path in batch:

                You want the path to the folder that the script is in? %~dp0

                Yes, And again - it may not really be possible in Batch.. and by path:

                \server\share1\sharename2\some othershare\departmentshare(files)

                was changed to

                \server\share1\sharename2\some othershare\department_share name of something(files)

                1 Reply Last reply Reply Quote 0
                • DashrenderD
                  Dashrender
                  last edited by

                  can you show us the script?

                  I think you just want to replace \server\share1\folder1\folder2\folder3\file to .\file, assuming everything is in that one folder.

                  gjacobseG 1 Reply Last reply Reply Quote 1
                  • gjacobseG
                    gjacobse @Dashrender
                    last edited by

                    @Dashrender said in Relative path in batch:

                    can you show us the script?

                    I think you just want to replace \server\share1\folder1\folder2\folder3\file to .\file, assuming everything is in that one folder.

                    Not everything is, but I will give that a shot on the items that are.

                    1 Reply Last reply Reply Quote 0
                    • F
                      flaxking
                      last edited by

                      .\ Won't necessarily refer to the folder the script is in, it will refer to the working directory at the time that the script is launched.

                      %~dp0 refers to the directory the script is in, but I don't recall if it works for Network shares.

                      DashrenderD 1 Reply Last reply Reply Quote 0
                      • DashrenderD
                        Dashrender @flaxking
                        last edited by

                        @flaxking said in Relative path in batch:

                        .\ Won't necessarily refer to the folder the script is in, it will refer to the working directory at the time that the script is launched.

                        %~dp0 refers to the directory the script is in, but I don't recall if it works for Network shares.

                        Good point. mapped drives would help this, even if you're mapping it long enough for the script to run, then unmapping it at the end.

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post