WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mtruong1 on September 22, 2014, 07:59:33 AM

Title: Passing parameter
Post by: mtruong1 on September 22, 2014, 07:59:33 AM
In DOS, I can pass parameter as %username% onto a DOS script, for example

cd "d:\users\%username%\abc\def"

and the script would pass the actual username (ie, john, michael) as a replacement for %username% when it run.

In WinBatch, I run the following command

DirChange (d:\users\%username%\abc\def) and Winbatch would not recognize %username%

How can I resolve this issue??

thx
Title: Re: Passing parameter
Post by: JTaylor on September 22, 2014, 09:13:32 AM
Take a look at the Environment() function.

Jim
Title: Re: Passing parameter
Post by: td on September 22, 2014, 02:04:25 PM
Quote from: mtruong1 on September 22, 2014, 07:59:33 AM
In DOS, I can pass parameter as %username% onto a DOS script, for example

cd "d:\users\%username%\abc\def"

and the script would pass the actual username (ie, john, michael) as a replacement for %username% when it run.

In WinBatch, I run the following command

DirChange (d:\users\%username%\abc\def) and Winbatch would not recognize %username%

How can I resolve this issue??

thx

Code (winbatch) Select

username = Environment('username')
DirChange ('d:\users\%username%\abc\def')