Home / Microsoft / Microsoft DOS / Batch Programs Thread.
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: 1 ... 35 36 [37] - (Bottom) Print
Author Topic: Batch Programs Thread.  (Read 96259 times)
patio
Moderator
Genius



Thanked: 1023
Posts: 10,558

Experience: Beginner
OS: Windows 7


Maud' Dib

« Reply #540 on: November 15, 2011, 06:28:53 PM »

That's just perfect...why are we still even entertaining this ? ?
IP logged

   
"
All generalizations are false, including this one.  "
ekto
Greenhorn



Posts: 7

Experience: Beginner
OS: Unknown

« Reply #541 on: December 01, 2011, 12:18:47 PM »

hey guys new here, i wanted to pick your brains as im struggling to find an answer to what im looking for!

basically ive got some software that my dad had wrote by a programmer it ships with hardware he sells, (vehicle diagnostics etc) im editting his installer that runs from a usb key which also acts as a security dongle so it has to be by dongle and i cant switch to CD or DVD , it uses a batch file which i will eventually convert into a .exe as long as the code all works

the batch file works great, it all installs fine and goes thru spot on and everything is fine, the only thing i cant get to grips with is i would like to delete some driver files from the usb once it has installed once this is so people who try to steal the software once its been installed once will be missing crucial drivers(long story but go with me on this one for now!) my problem is when you put in a usb key, its normally a different drive letter everytime, so i cant link to a static drive letter to delete from  ie; C:/ D:/ etc etc, ive tried using CD\ (to go to top directory) and then DEL for delete but i cant seem to get it to work, im not overly experienced with ms dos, but ive coded in other languages so i understand the fundamentals just not the syntax,

heres what i have:

@ECHO Y
CD\
del folder/file1.dll
del folder/file2.dll
del folder/file3.dll
del folder/file4.dll

i know its probably rubbish but hey ive tried for days on this before asking for help! thanks

Steve
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,367

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #542 on: December 01, 2011, 12:53:44 PM »

I expect you know about the replaceable parameters %1 to %9. Well, there is another one: %0 (that's a zero after the percent symbol). This is a special variable: it contains the batch script's identity.

If you have a batch script called Hello.bat and it contains this line:

Code: [Select]
echo This script is %0
When it runs, on the screen will be echoed:

Code: [Select]
This script is Hello.bat
You can use the same standard variable modifiers with the tilde ~ symbol that work with %1 to %9 and also with FOR variables.

Code: [Select]
    %~I         - expands %I removing any surrounding quotes (")
    %~fI        - expands %I to a fully qualified path name
    %~dI        - expands %I to a drive letter only
    %~pI        - expands %I to a path only
    %~nI        - expands %I to a file name only
    %~xI        - expands %I to a file extension only
    %~sI        - expanded path contains short names only
    %~aI        - expands %I to file attributes of file
    %~tI        - expands %I to date/time of file
    %~zI        - expands %I to size of file

The I is just a letter used for explanation purposes in the documentation for the FOR command.

So in a batch script %~d0 will expand to the drive letter of the drive that the script is on. %~d0:\ is the root directory of that drive. 





IP logged

ekto
Greenhorn



Posts: 7

Experience: Beginner
OS: Unknown

« Reply #543 on: December 01, 2011, 01:29:56 PM »

thanks this makes sense, but defo aches my brain haha!
IP logged
patio
Moderator
Genius



Thanked: 1023
Posts: 10,558

Experience: Beginner
OS: Windows 7


Maud' Dib

« Reply #544 on: December 01, 2011, 04:54:46 PM »

thanks this makes sense, but defo aches my brain haha!

Not quite sure what that means so i'll have to say i agree...
IP logged

   
"
All generalizations are false, including this one.  "
Geek-9pm
Sage



Thanked: 327
Posts: 8,050

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #545 on: December 01, 2011, 06:18:05 PM »

Defo. a shortening of definitely for use when responding in agreement ...

...the defo program runs on an Apple OS, not MS DOS.
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,367

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #546 on: December 02, 2011, 12:12:15 AM »

%~d0:\ is the root directory of that drive.

Correction: %~d0\ is the root directory of the drive on which the batch file is located. (The colon is included automatically)
IP logged

Geek-9pm
Sage



Thanked: 327
Posts: 8,050

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #547 on: December 02, 2011, 08:10:22 AM »

Correction: %~d0\ is the root directory of the drive on which the batch file is located. (The colon is included automatically)
Where do you find this stuff?
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,367

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #548 on: December 02, 2011, 11:02:39 AM »

Where do you find this stuff?

It's all in the Microsoft Command Line Reference
IP logged

Geek-9pm
Sage



Thanked: 327
Posts: 8,050

Computer: Specs
Experience: Familiar
OS: Windows XP


Geek After Dark

« Reply #549 on: December 02, 2011, 11:32:21 AM »

It's all in the Microsoft Command Line Reference
Like this?
Command-line Reference  Updated: October 25, 2010
http://technet.microsoft.com/en-us/library/cc754340%28WS.10%29.aspx
IP logged
Salmon Trout
Prodigy



Thanked: 501
Posts: 7,367

Computer: Specs
Experience: Guru
OS: Linux variant

1
« Reply #550 on: December 02, 2011, 11:39:07 AM »

Like this?
Command-line Reference  Updated: October 25, 2010
http://technet.microsoft.com/en-us/library/cc754340%28WS.10%29.aspx

Yup.
IP logged

millergram
Rookie



Posts: 30

Experience: Beginner
OS: Windows Vista

« Reply #551 on: December 23, 2011, 02:08:24 PM »

Heres A batch For a Alarm Clock :)

Code: [Select]
@echo off
Title Alarm
:Main1
set HR=00
set MN=00
set SC=00
:Main
cls
Echo.set Time
Echo.%time%
Echo.Use Time Format 00:00:00
set /p HR=Hours:
goto T1
:T1
cls
Echo.set Time
Echo.%time%
Echo.%HR%:%MN%:%SC%
set /p MN=Mins:
Goto T2
:T2
cls
Echo.set Time
Echo.%time%
Echo.%HR%:%MN%:%SC%
set /p SC=Seconds:
goto T3
:T3
cls
Echo.set Time
Echo.%time%
Echo.%HR%:%MN%:%SC%
set /p Ok=Yes:1? No:2?=
if "%Ok%"=="1" Goto Cont
if /i "%Ok%"=="yes" Goto Cont
if "%Ok%"=="2" Goto Main1
if /i "%Ok%"=="no" Goto Main1
if "%Ok%"=="" Goto T3
if "%Ok%"=="%Ok%" Goto T3
:Cont
set TT=%HR%:%MN%:%SC%.00
cls
title %TT%
echo.%time%
if "%time%"=="%HR%:%MN%:%SC%.00" goto wake
goto Cont
:wake
Echo.Wake Up!!!
cd %programfiles%
cd *windows Media*
wmplayer "Path of your audio file"
Echo.Press A Key To Turn Off.
pause>nul
IP logged
Pages: 1 ... 35 36 [37] - (Top) Print 
Home / Microsoft / Microsoft DOS / Batch Programs Thread. « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.105 seconds with 21 queries.