1.

Solve : help!!!!!! i cant find how to open a shortcut on the same drive as the .bat file?

Answer»

im writing a BATCH file and i cant find anywhere that will show me a peice of code that will open a shortcut that is on the same drive and folder as the bat file

its probably realy simple like 3 words but i cant remember

the file is phun.ink


also can some one post a code snipit for a .bat file to cheak if a file or drive exists


one more question how do you make a code that picks a random number in a range
so it will pick a random number out of a list

and how can you make an autorun fileWhat have you GOT so far?

Can I confirm you want the batch file to open a shortcut on the same drive? (or same directory, as in it's in the same folder as the batch file)never mind about that now ive just rememberd it so my other qustion is what peice of code can determin if a disk drive existsQuote from: steven32collins on January 03, 2009, 05:26:09 AM

never mind about that now ive just rememberd it so my other qustion is what peice of code can determin if a disk drive exists

Code: [Select]if exist "c:\" echo Drive C existsQuote
Code: [Select]if exist "c:\" echo Drive C exists

You should add this after that.

Code: [Select]if not exist "c:\" echo Drive C doesn't exist
So then if it doesn't exist it at LEAST gives a message instead of the PROGRAM just exiting out.


Quote from: BatchFileCommand on January 03, 2009, 09:40:47 AM
Quote
Code: [Select]if exist "c:\" echo Drive C exists

You should add this after that.

Code: [Select]if not exist "c:\" echo Drive C doesn't exist
So then if it doesn't exist it at least gives a message instead of the program just exiting out.


maybe, but this is the original question

Quote
what peice of code can determin if a disk drive exists

Even better

Code: [Select]if exist "c:\" (echo Drive C exists) ELSE (echo Drive C does not exist)
ive been using al of this code for a bat file for my memory stick so when i plug the usb flash drive in the bat file opens and cheaks for other memory sticksJust so you know, .lnk files are in a registry along with a list of other extensions that don't show up. As long as that script exists, you can't see the extension (neither can DOS), so you can't open it except by Double-Clicking.

A random number in a range? EASY!

Code: [Select]@echo off
:number
set number=%random%
rem The above line is so %random% will remain as long as we need.
if %number% GEQ %bottomrange% goto 1
rem %bottomrange% is the bottom number. The number can be %bottomrange% and up.
goto number
:1
if %number% LEQ %toprange% echo %number%
rem %toprange% is the maximum number. The numbers will be that number AND below it.
goto number
Replace %bottomrange% and %toprange% with the bottom and the top of your range.

You can remove the REM if you like. Its just there to explain how the code works.


Discussion

No Comment Found