Jump to content

Use HD name instead of letter


Hurtcake

Recommended Posts

Im writing some batch scrips to make my life easier. I have the scripts on a usb-key, and i want them to work even if i move them around, to lets say the desktop.

Untill now im been using example: .downloadsccleaner.exe to run the files. But that won't work if i move them. My question is, is it possible to make a path using the name of the HD or the usb-key instead of x:downloadsccleaner.exe  (cause the letter may change from time to time)

If that made some sense :P

Or does anyone else have some better ideas or tips? :)

Link to comment
Share on other sites

It will only work if the bat script is in the root of the folder where the rest of the files are. So if you want it to run it from "./bat files/downloads/ccleaner.exe" then make sure the bat script is in a folde, let's say "bat files" and then the downloadsccleaner.exe is within that "bat files" folder. Then whenever you move the "bat files" folder any of the bat files you click on will still run, even when copied from the flash drive to the hard drive.

Link to comment
Share on other sites

It will only work if the bat script is in the root of the folder where the rest of the files are. So if you want it to run it from "./bat files/downloads/ccleaner.exe" then make sure the bat script is in a folde, let's say "bat files" and then the downloadsccleaner.exe is within that "bat files" folder. Then whenever you move the "bat files" folder any of the bat files you click on will still run, even when copied from the flash drive to the hard drive.

You're talking about moving the whole folder around, right?

I wanted to keep the files on the usb-drive, and just have the batch file on my desktop. Without using the usb-drive letter.

Anyway I played around some more, and i found a solution that worked for me

@echo off
:: variables
if exist "d:systemscripts" set drive=d:
if exist "e:systemscripts" set drive=e:
if exist "f:systemscripts" set drive=f:
if exist "g:systemscripts" set drive=g:
if exist "h:systemscripts" set drive=h:
if exist "i:systemscripts" set drive=i:
if exist "j:systemscripts" set drive=j:
if exist "k:systemscripts" set drive=k:

start %drive%systemccleanerccleaner.exe
exit

Then the batch wil automatic assign the right drive letter, and i dont have to worry about the drive letter if the computer decide to change it. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...