Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. Clever Code
  4. subst what?

subst what?

Scheduled Pinned Locked Moved Clever Code
helpquestion
10 Posts 8 Posters 0 Views 1 Watching
  • 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.
  • Y Offline
    Y Offline
    Yusuf
    wrote on last edited by
    #1

    I got a source code for an old application from the repository. The path to the projects in the solution file was set as absolute pointing to the D: drive. I have single disk and D: is used by the DVD. Changed DVD letter to E and created a virtual drive D: using subst subst D: C:\ this worked like a charm, but it means I would have to subst the drive every time I boot the machine. So I created a batch file stuck it to the startup folder and called subst from the batch file. :) This was all good except I called my batch file subst.bat. Guess what happens when the batch file executes, Hmmm infinite loop calling it self. ;P

    /* I can C */ // or !C Yusuf

    B L D V 4 Replies Last reply
    0
    • Y Yusuf

      I got a source code for an old application from the repository. The path to the projects in the solution file was set as absolute pointing to the D: drive. I have single disk and D: is used by the DVD. Changed DVD letter to E and created a virtual drive D: using subst subst D: C:\ this worked like a charm, but it means I would have to subst the drive every time I boot the machine. So I created a batch file stuck it to the startup folder and called subst from the batch file. :) This was all good except I called my batch file subst.bat. Guess what happens when the batch file executes, Hmmm infinite loop calling it self. ;P

      /* I can C */ // or !C Yusuf

      B Offline
      B Offline
      BadKarma
      wrote on last edited by
      #2

      Nah, even if you would have called it something meaningfull, Murphy would kick in and it would misbehave in another obscure way.

      codito ergo sum

      1 Reply Last reply
      0
      • Y Yusuf

        I got a source code for an old application from the repository. The path to the projects in the solution file was set as absolute pointing to the D: drive. I have single disk and D: is used by the DVD. Changed DVD letter to E and created a virtual drive D: using subst subst D: C:\ this worked like a charm, but it means I would have to subst the drive every time I boot the machine. So I created a batch file stuck it to the startup folder and called subst from the batch file. :) This was all good except I called my batch file subst.bat. Guess what happens when the batch file executes, Hmmm infinite loop calling it self. ;P

        /* I can C */ // or !C Yusuf

        L Offline
        L Offline
        Luke Lovegrove
        wrote on last edited by
        #3

        Wow, there's a blast from the past. I don't recall any problems having the subst command being run from a batch file though... A silly trick I used to play though used the subst program with the assign program was to create a substitute drive, assign the c: drive to be the logical equivalent of the substitute drive and the remove the substitute drive. This had the side effect of logically removing the c: drive as well, rendering the drive inaccessible until a reboot. Although it wasn't too bad if you wanted a rather crude form of "security" in the days of DOS... you could show only the parts of the disk you wanted to.

        ------------------------ Luke Lovegrove ------------------------

        Y T 2 Replies Last reply
        0
        • L Luke Lovegrove

          Wow, there's a blast from the past. I don't recall any problems having the subst command being run from a batch file though... A silly trick I used to play though used the subst program with the assign program was to create a substitute drive, assign the c: drive to be the logical equivalent of the substitute drive and the remove the substitute drive. This had the side effect of logically removing the c: drive as well, rendering the drive inaccessible until a reboot. Although it wasn't too bad if you wanted a rather crude form of "security" in the days of DOS... you could show only the parts of the disk you wanted to.

          ------------------------ Luke Lovegrove ------------------------

          Y Offline
          Y Offline
          Yusuf
          wrote on last edited by
          #4

          Luke Lovegrove wrote:

          Wow, there's a blast from the past. I don't recall any problems having the subst command being run from a batch file though...

          The problem was not with subst. I called my batch file subst.bat. inside the batch file I called subst. So, first it looks in the current working dir and it finds subst.bat and it called it, what follows is, you know ... :laugh: :laugh: :laugh:

          /* I can C */ // or !C Yusuf

          1 Reply Last reply
          0
          • Y Yusuf

            I got a source code for an old application from the repository. The path to the projects in the solution file was set as absolute pointing to the D: drive. I have single disk and D: is used by the DVD. Changed DVD letter to E and created a virtual drive D: using subst subst D: C:\ this worked like a charm, but it means I would have to subst the drive every time I boot the machine. So I created a batch file stuck it to the startup folder and called subst from the batch file. :) This was all good except I called my batch file subst.bat. Guess what happens when the batch file executes, Hmmm infinite loop calling it self. ;P

            /* I can C */ // or !C Yusuf

            D Offline
            D Offline
            Daniel Grunwald
            wrote on last edited by
            #5

            Put the following line into a .bat file: %0|%0 Do you know what that 5-byte .bat-file does? WARNING: YOU MAY LOOSE UNSAVED DATA IF YOU TRY TO RUN IT! If you really want to try it, use a virtual machine! Or if you are really evil: put it on a co-worker's desktop and wait to see if he is curious enough to run it.

            J R 2 Replies Last reply
            0
            • D Daniel Grunwald

              Put the following line into a .bat file: %0|%0 Do you know what that 5-byte .bat-file does? WARNING: YOU MAY LOOSE UNSAVED DATA IF YOU TRY TO RUN IT! If you really want to try it, use a virtual machine! Or if you are really evil: put it on a co-worker's desktop and wait to see if he is curious enough to run it.

              J Offline
              J Offline
              Jay Gatsby
              wrote on last edited by
              #6

              Now I have to know. Do tell what it does... please? :-O

              -Gatsby

              D 1 Reply Last reply
              0
              • J Jay Gatsby

                Now I have to know. Do tell what it does... please? :-O

                -Gatsby

                D Offline
                D Offline
                Daniel Grunwald
                wrote on last edited by
                #7

                %1, %2, ... are the arguments to the batch file. %0 is the name of the batch file itself (the command line used to start it). So the .bat file calls itself and pipes its output into another copy of itself. Piping works by running the processes in parallel, to pipe into a .bat file a new instance of cmd.exe is created. So the batch file starts two copies of itself in parallel => it's a fork bomb[^]

                1 Reply Last reply
                0
                • Y Yusuf

                  I got a source code for an old application from the repository. The path to the projects in the solution file was set as absolute pointing to the D: drive. I have single disk and D: is used by the DVD. Changed DVD letter to E and created a virtual drive D: using subst subst D: C:\ this worked like a charm, but it means I would have to subst the drive every time I boot the machine. So I created a batch file stuck it to the startup folder and called subst from the batch file. :) This was all good except I called my batch file subst.bat. Guess what happens when the batch file executes, Hmmm infinite loop calling it self. ;P

                  /* I can C */ // or !C Yusuf

                  V Offline
                  V Offline
                  VentsyV
                  wrote on last edited by
                  #8

                  Along the similar lines: I have a function that expands environmental variables. Thats being called by a number of programs. So for example, if I have MYROOT=C:\rootdir, then I might have a setting in my config file such as run %MYROOT%\myexec.exe My function would then translate to: run c:\rootdir\myexec.exe. So far so good. Somehow, I had variable that was set to MYVAR=%MYVAR% .... can you guess what happened when the code attempted expanding that (recursively) ?? :-\ Obviously, it was not as simple as MYVAR=%MYVAR%, it is just an example.

                  1 Reply Last reply
                  0
                  • D Daniel Grunwald

                    Put the following line into a .bat file: %0|%0 Do you know what that 5-byte .bat-file does? WARNING: YOU MAY LOOSE UNSAVED DATA IF YOU TRY TO RUN IT! If you really want to try it, use a virtual machine! Or if you are really evil: put it on a co-worker's desktop and wait to see if he is curious enough to run it.

                    R Offline
                    R Offline
                    Reelix
                    wrote on last edited by
                    #9

                    *Runs* *Watches for a few seconds* *Browses CP abit* *Attempts to click out of the 500 million error boxes* *Holds down Ctrl+B for about a minute, alternating with Alt+F4's, and Right-Click Closes seconds* VICTORY! :D

                    -= Reelix =-

                    1 Reply Last reply
                    0
                    • L Luke Lovegrove

                      Wow, there's a blast from the past. I don't recall any problems having the subst command being run from a batch file though... A silly trick I used to play though used the subst program with the assign program was to create a substitute drive, assign the c: drive to be the logical equivalent of the substitute drive and the remove the substitute drive. This had the side effect of logically removing the c: drive as well, rendering the drive inaccessible until a reboot. Although it wasn't too bad if you wanted a rather crude form of "security" in the days of DOS... you could show only the parts of the disk you wanted to.

                      ------------------------ Luke Lovegrove ------------------------

                      T Offline
                      T Offline
                      The Nightcoder
                      wrote on last edited by
                      #10

                      Neat! chroot in DOS... and MS hasn't figured that out for their FTP server YET!

                      -- Peter

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups