Link to home
Start Free TrialLog in
Avatar of becraig
becraigFlag for United States of America

asked on

Delayedexpansion WOES

I have a startup script that needs to grab values from another script. (cmd files)

The variable values do not populate without delayedexpansion ( I am ok with this except for one thing)

I have a value that contains a "!" which gets lost once read with delayed expansion on - I am unable to manually adjust this value since it is dynamic.

Any ideas on how to work around this ?


Example:

net use !server!\filepath /user:!user! '!password!'

The password sometimes contains an exclamation and causes a break is there any way to handle this ?
SOLUTION
Avatar of John
John
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should only have issues if you pass the expanded value containing an exclamation mark again to a "function" or batch (both via call), at which time it gets reinterpreted.
The only reliable way is to switch off delayed expansion for as much as possible. Or switch to using PowerShell ;-).
Avatar of becraig

ASKER

Thanks guys, I really thought I left this crap behind me  :~(

So much for winpe and safeos testing.

Qlemo I wish I could use posh :~)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Prew
Bill Prew

Interesting, I always love when a solution isn't a solution...