Batch files: Snippets 1: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(New page: <span id="top"></span> <div style="padding:0;margin:0; border-bottom:3px inset #000000"> {| | MPG UniCenter || Batch Files: [[Batch files: Snippets 1 | Infor...)
 
mNo edit summary
Line 129: Line 129:


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== Current drive letter ===
=== Current drive letter 1===
To pick up the current drive letter (where the batch file resides) use this:
To pick up the current drive letter (where the batch file resides) use this:
{| cellpadding="4" cellspacing="1" style="background:#000000;"
{| cellpadding="4" cellspacing="1" style="background:#000000;"
Line 147: Line 147:


'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== Current drive letter 2===
If all your batch files are located on the same drive and not run from other batch files on different drives this solution by '''jacob lee''' is worth considering. I lifted this from the [http://forum.uniformserver.com/index.php?showtopic=1481&hl= forum] and reproduce as is:
using %CD% we can do a lot of things.
open cmd.exe and type "echo %CD%". it will show like "C:\Documents and Settings\jacob lee"
type "echo %CD:~0,1% then it will show "C"
so we can change "set Disk=h" to:
<pre>
set Disk=%CD:~0,1%
</pre>
'''''[[#top | Top]]'''''
== Read and Write a variable to a file ==
== Read and Write a variable to a file ==
Occasionally I need to write a variable to a text file and read it back using some other batch file. It’s relatively easy to do as these examples show:
Occasionally I need to write a variable to a text file and read it back using some other batch file. It’s relatively easy to do as these examples show:
Line 561: Line 579:


{|  
{|  
| [[Image:uc_small_logo.gif]] || [[User:Ric|Ric]]
| [[Image:uc_small_logo.gif]] || [[User:Ric|Ric]]  
|}
|}


[[Category: UniCenter]]
[[Category: UniCenter]]

Navigation menu