
Env variable in Windows XP for batch scripting?
I normally shell script in Unix, but I’ve a need to create a batch script in Windows Server 200x (not sure of which).
I need to create log files with the current date.
A bit of poking around led me to the %date% env variable and some substring-type functions on it.
Unfortunately, I am seeing the following behavior at the command line prompt:
C:> set stuff=%date%
C:> echo %stuff%
%date%
The variable %stuff% doesn’t contain the translated date, but, rather, contains the string ‘%date%.
When I put those lines in a cmd file, it works just fine. Even more confusing, when my co-worker tries it on an identically-configured machine, %stuff% has the translated date.
Why would %stuff% not translate interactively for me? Any ideas?
Thanks!
The expansion of %date% by the current date depends on CMD.EXE Command Extensions and Delayed Expansion. In some cases, the expansion occur only in Batch files (not in the command-line), but if Command Extensions are disabled, %date% is always %date%.
Command Extensions are enabled by /E:ON switch in CMD or by several other methods/defaults. You may read the details about this matter in SET /?, CMD /? and SETLOCAL /?.
Regards…
PSP LED 200X 爆閃改裝紅+藍有警察的味道
| IBM LENOVO X200 X200s X201 X201s 12.1″ WXGA LED LCD LTN121AT07 42T0712 42T0713 $143.07 |
|
| 200 x Carbon Film Resistors 1/4W 220 Ohm 5% For 5V LED $4.48 |
|
| 200 x Carbon Film Resistors 1/4W 470 Ohm 5% For 5V LED $4.48 |
|
| 200 x Resistors 220 Ohm for 5v led 1/4W 5% Carbon Film $4.48 |
|
| 200 x Resistors 470 Ohm for 12v led 1/4W 5% Carbon Film $4.48 |
|
| 200 x 5mm Bi-Color LEDs Red/Green 3-Pins Center Cathode $16.99 |
|
| 200X 5mm 8Kmcd 4 Pins Common Cathod MultiColor RGB LED $70.99 |
|
| Upgrade Full-Motion26″-42″ LCD/LED/Plasma TV Wall Mount w/ Max VESA 200×200 mm $49.95 |
|
| NEW!! 200X 1.3 Mega Pixels 8-LED USB Digital Microscope $9.99 |
|
| 200x Zoom 1.3 Mega Pixels 4 LED Light USB Digital Optical Microscope Magnifier $33.45 |
|
| 200x 5mm Green LED Super Bright Round Light Bulb P 5mmG D $0.84 |
|
| 200 x 5mm round warm white LED Ultra Bright 14000MCD $15.00 |
|
| Magnifier Toy 200x 4LED Kids Science USB Digital Optical Microscope Professional $33.45 |
|
| 200 x Blue LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| 200 x Red LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| 200 x UV LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| USB Magnifier Camera 200 x 4LED Still Image / Video Digital Optical Microscope $33.45 |
|
| 200x 2x5x7mm Green LEDs Lamp Light Green Diffused Lens $12.99 |
|
| 200x 2x5x7mm Yellow LED Lamp Light Yellow Diffused Lens $12.99 |
|
| 200x 3mm RGB Rainbow Flash Fast & Slow by turns LED FR $19.99 |
|
| 200x 5mm RGB Rainbow Flash Fast & Slow by turns LED FR $19.99 |
|
| 200x 5x5x7mm Green LEDs Lamp Light Green Diffused Lens $14.99 |
|
| 200x 5x5x7mm Yellow LED Lamp Light Yellow Diffused Lens $14.99 |
|
| 200x Amber LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| 200x Green LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| 200x White LED Lamp Light Set 25cm Pre Wired 5mm 12V DC $54.99 |
|
| 200x 5mm Green LED Super Bright Round Light Bulbs X $0.88 |
|
| New 200X 3MM Super Bright Yellow LED Lamp 12,000mcd $26.00 |
|
| 200×200 VESA Adapter PLASMA LCD LED TV WALL MOUNT BRACKET 200×100 100×100 75×75 $19.99 |
|
| 200 x 100 x 17 mm Aluminum Heat Sink for LED and Electronic Components $22.50 |
|
| 200X 1.3 Mega Pixels 8-LED USB Digital Microscope NEW!! $9.99 |
|
| Universal 200×200 VESA Conversion Plate Adapter LCD LED TV Wall Mount Brackets $7.99 |
|
| Universal VESA Adapter Plate Mounts LCD Plasma LED TV Wall Mount Bracket 200×100 $9.99 |
|
| Y 200X 5mm White LED Super Bright Round Light Bulb lamp $0.84 |
|
| Y 200x 5mm Green LED Super Bright Round Light Bulbs G $0.84 |
|
| Lot of 200 X 10mm Amber LED 6000 mcd Free Resistors $34.99 |
|
| Lot of 200 X 10mm Green LED 10000 mcd Free Resistors $46.99 |
|
| Lot of 200 X 3mm Amber LED 10000 mcd Free Resistors $13.99 |
|
| Lot of 200 X 3mm Blue LED 10000mcd Free Resistors $13.99 |
|
| Lot of 200 X 3mm Green LED 15000 mcd Free Resistors $13.99 |
|
| VideoSecu Flush TV Wall Mount for Plasma Flat Panel Screen Monitor TV Loading Capacity up to 80 lbs VESA 50/75/100/200×100/200 M19 $15.96 Flush Wall Mount for Flat Panel Screen LCD Monitor TV. Slim flat LCD mounts are incredibly easy to install, and feature a low-profile, sliding plate design that places the display very close to the wall for a clean look, while also providing a unique combination of simplicity and security…. |
|
| Feit Electric BPXN20/G8/3 Xenon 20-Watt, 120-Volt G8 Base, 3 Pack $7.99 This is a 3 pieces pack of XENON HALOGEN BULB 20 watts 120 volts JCD G8 Bi-Pin base clear finishFeatures: – New Xenon technology- White – cooler – longer life- Bi-pin, G8 base- Great for accent lighting, display or task lights- 20 Watt – 120 volt- Replaces American Lighting Part # LXCP-20BP… |
|
| Rayovac Platinum Pre-Charged NiMH AA Size Batteries, 4 Count $5.00 Rayovac Platinum nickel metal hydride (NiMH) rechargeable batteries are the most economical battery solution for high-drain devices like digital cameras, portable video games, kids toys and wireless gaming accessories.The Latest Rechargeable Technology View larger.Low Self Discharge: These NiMH batteries have improved charge retention. With Low Self Discharge, the batteries are able to retain 70% … |
|
| Tenergy TN141 2 Bay 9V Smart Charger with 4 pcs 9V 250mah NiMH Rechargeable Batteries $26.97 Charger Features * Rapid charging Features * Applicable for 9V rechargeable Ni-MH batteries |
|