Re: set user=%username%
- From: "Pegasus \(MVP\)" <I.can@xxxxxxx>
- Date: Thu, 16 Jun 2005 14:41:49 +1000
Your most recent feedback confirms that Windows is
working exactly as it should. The variable %user% is
set as expected.
However . . . it seems that you are trying to do something
entirely different, without actually saying so. I suspect
that you wish to set the %user% variable during the logon
process, and then expect to see it in other processes that
are launched subsequently.
This is not the way environmental variables work. Each
child process "inherits" a copy of the parent environmental
variables. The child process can do whatever it likes with
these variables, because they are strictly local. The do NOT
get passed to other processes! I encourage you to try this
little test:
1. Start a Command Prompt.
2. Type this: set MyName=Roland
3. Type this: echo %MyName%
4. Type this: cmd
5. Type this: echo %MyName%
6. Type this: set YourName=Pegasus
7. Type this: echo %YourName%
8. Type this: exit
9. Type this: echo %YourName%
If you wish to set a variable during the logon process
and make it available to other processes then you must
use setx.exe from the Windows Resource Kit. Note that
any such variable will be inherited by processes launched
later on but NOT by pre-existing processes.
"roland" <roland@xxxxxxxxxxx> wrote in message
news:OMKNbkicFHA.1356@xxxxxxxxxxxxxxxxxxxxxxx
> Pegasus you do understand that i am trying to set a variable "user" to be
> the same as what ever %username% in this case my logon name "rolandp"
>
> I am trying to get this done with a script i have on my domain control
> sysvol folder.
>
> I also have the group policy setting under user configureration enabled
for
> the login in script
>
> Hope what i said makes sense
>
> Roland
>
> user=RolandP
> user1=RolandP
> USERDNSDOMAIN=gladneycenter.org
> USERDOMAIN=GLADNEYNT
> USERNAME=RolandP
> USERPROFILE=C:\Documents and Settings\rolandp
> usertest=This is a long string. This is a long string. This is a long
>
>
> "Pegasus (MVP)" <I.can@xxxxxxx> wrote in message
> news:uFxYcOicFHA.3464@xxxxxxxxxxxxxxxxxxxxxxx
> > Your feedback tells me a couple of things:
> > - You're running cmd.exe as a command processor, not
> > command.com. That's the way it should be.
> > - The system variable %UserName% is set, as it should be.
> >
> > Now let's try a little batch file:
> > @echo off
> > set user=%UserName%
> > set user1=%UserName%
> > set usertest=This is a long string. This is a long string. This is a
long
> > string.
> > set user > c:\test.txt
> >
> > Run this batch file, then paste the contents of c:\test.txt
> > into your reply.
> >
> >
> > "roland" <roland@xxxxxxxxxxx> wrote in message
> > news:eXyLNJicFHA.2076@xxxxxxxxxxxxxxxxxxxxxxx
> >> As you can see my user variable doesn't get set.
> >>
> >> any ideas ?
> >>
> >> Roland
> >>
> >>
> >> C:\>set user
> >> USERDNSDOMAIN=gladneycenter.org
> >> USERDOMAIN=GLADNEYNT
> >> USERNAME=rolandp
> >> USERPROFILE=C:\Documents and Settings\rolandp
> >>
> >> C:\>set | find/i "comspec"
> >> ComSpec=C:\WINDOWS\system32\cmd.exe
> >>
> >> C:\>
> >>
> >>
> >>
> >> "Pegasus (MVP)" <I.can@xxxxxxx> wrote in message
> >> news:uFH8jqhcFHA.2980@xxxxxxxxxxxxxxxxxxxxxxx
> >> >
> >> > "roland" <roland@xxxxxxxxxxx> wrote in message
> >> > news:uAzaNBfcFHA.2960@xxxxxxxxxxxxxxxxxxxxxxx
> >> >> I have a batch file in my sysvol and a group policy object for it.
> >> >>
> >> >> Is this a valid command "set user=%username%" ?
> >> >>
> >> >> when I run the set cmd at the dos prompt I don't get the user
variable
> > in
> >> >> the list.
> >> >>
> >> >> Windows xp pro workstations, Windows 2003 servers and domain
> >> >> Moved all my data from my Novell servers to Microsoft over the
weekend
> >> >>
> >> >> All need to complete this and get rid of the Novel is to be able to
> >> >> set
> >> > that
> >> >> one variable.
> >> >>
> >> >> Thanks Roland
> >> >>
> >> >>
> >> >
> >> > What do you get when you type thes commandd at the Command Prompt?
> >> >
> >> > set user
> >> > set | find /i "comspec"
> >> >
> >> >
> >>
> >>
> >
> >
>
>
.
- Follow-Ups:
- Re: set user=%username%
- From: Torgeir Bakken \(MVP\)
- Re: set user=%username%
- References:
- set user=%username%
- From: roland
- Re: set user=%username%
- From: Pegasus \(MVP\)
- Re: set user=%username%
- From: roland
- Re: set user=%username%
- From: Pegasus \(MVP\)
- Re: set user=%username%
- From: roland
- set user=%username%
- Prev by Date: Re: set user=%username%
- Next by Date: Re: Replacing a primary domain controller
- Previous by thread: Re: set user=%username%
- Next by thread: Re: set user=%username%
- Index(es):
Relevant Pages
|