Need Help Setting Variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Im pretty new to scripting but I need help getting/setting a variable
(don't know if Im saying that right)


Basically what I want to do is have the script ask for the username and then
be able to assign it as a variable(Again, excuse me if I'm not using the
correct words).

Heres what I have now.

net use B: \\itchy\share
net use Z: \\itchy\usmt

md b:\%computername%_%1

z:\scanstate b:\%computername%_%1 /user:%1 /i:migsys.inf /i:miguser.inf
/i:sysfiles.inf /c /o /v:1 /l:b:\Logs\%computername%_%1.txt

net use B: /delete
net use Z: /delete

shutdown -l


This works great but instead of having to open command and run
bat.cmd dlinton

I want the script to ask me the username and then substitute that with the
%1 or what ever variable names.

Thanks Any help appreicaited
Donovan

Also I will gladly take suggestions on the rest of the script.
 
Hello, Donovan:
On Sat, 5 Feb 2005 08:11:01 -0800: you wrote...

DL> I want the script to ask me the username and then substitute that with
DL> the %1 or what ever variable names.

set /p ThisUser="Enter your username: "
echo %ThisUser%

Regards, Paul R. Sadowski [MVP].
 
Donovan Linton said:
Hi Im pretty new to scripting but I need help getting/setting a variable
(don't know if Im saying that right)


Basically what I want to do is have the script ask for the username and then
be able to assign it as a variable(Again, excuse me if I'm not using the
correct words).

First question: by "the username" do you mean the username of the currently
logged in user, or is this a script you will be running from an
administrative account to do some processing against a whole bunch of other
normal user accounts.

Second question: what operating system is running on the computer from which
this batch will be run?

Way at the bottom are a few suggestions...
Heres what I have now.

net use B: \\itchy\share
net use Z: \\itchy\usmt

md b:\%computername%_%1

z:\scanstate b:\%computername%_%1 /user:%1 /i:migsys.inf /i:miguser.inf
/i:sysfiles.inf /c /o /v:1 /l:b:\Logs\%computername%_%1.txt

net use B: /delete
net use Z: /delete

shutdown -l


This works great but instead of having to open command and run
bat.cmd dlinton

I want the script to ask me the username and then substitute that with the
%1 or what ever variable names.

Thanks Any help appreicaited
Donovan

Also I will gladly take suggestions on the rest of the script.

If this is running on an NT series system, and if the username is that of
the currently logged in user, then simply replace %1 with %username% in your
script. That environment variable is defined by the o/s to contain the name
of the currently logged in user, in much the same way that %computername%
gives the name of the computer.

If you actually need it to prompt for the username of another account, and
if you are running this from XP, w2k, or w2k3, then try this:

(set/p user=Enter the username to be processed: )
net use B: \\itchy\share
net use Z: \\itchy\usmt
REM - replace - md b:\%computername%_%1
md b:\%computername%_%user%REM - replace - z:\scanstate b:\%computername%_%1 /user:%1 /i:migsys.inf
/i:miguser.inf /i:sysfiles.inf /c /o /v:1 /l:b:\Logs\%computername%_%1.txt
z:\scanstate b:\%computername%_%user% /user:%user% /i:migsys.inf
/i:miguser.inf /i:sysfiles.inf /c /o /v:1
/l:b:\Logs\%computername%_%user%.txt
net use B: /delete
net use Z: /delete

shutdown -l

If you are running on NT or 9x, there are some workarounds available to
simulate the input functionality.


Scanstate seems to be used for migrating user profile information through an
o/s upgrade from 9x to 2k. Since you are explicitly doing a shutdown, it is
not clear to me what your answers are to my first question at the top.
Assuming this will be run by the user account being processed, and assuming
windows98, there is another way to determine the name of the current user.
There is at least one command whose output includes the name of the current
user on w98 systems (I think it is ipconfig/all, but lacking any w98 systems
at home, I am not sure). You could redirect this output to a file, and then
parse that file to extract the name.


/Al
 
All the systems are WinXP (I just noticed it said Win2000),and migrating to
new computers, I didn't user the %username% value because I will be logged in
as myself running the migration.

Thanks for your response.

I was put in charge up migrating my departments data, so any more suggestion
to make this process easier is greatly apprecitated.

Donovan
 
Donovan Linton said:
All the systems are WinXP (I just noticed it said Win2000),and migrating to
new computers, I didn't user the %username% value because I will be logged in
as myself running the migration.

Thanks for your response.

I was put in charge up migrating my departments data, so any more suggestion
to make this process easier is greatly apprecitated.

One suggestion I would seriously consider is to adopt a policy that storage
of departmental data NOT be allowed on workstations, but only on servers.

/Al
 
I dont have that type of access. I would like to have the script done from AD
and SMS.
I was put in charge of migrating all the data for my dept, and I was looking
for the easiest way to do that.

Donovan
 
Donovan Linton said:
I dont have that type of access. I would like to have the script done from AD
and SMS.
I was put in charge of migrating all the data for my dept, and I was looking
for the easiest way to do that.

I understood that. I was trying to suggest a company policy that would
prevent your ever having to do this again. Even though that is not what you
were asking for, I nonetheless assumed you might get some benefit from the
suggestion.

As for the task at hand, it is not clear to me what the intent is. Is it to:

- backup all information stored in all user profiles on a computer to be
replaced, so that the same data will just show up in the same place on the
new workstation?

- backup all information stored in all user profiles on a computer to be
replaced, so that the users can retrieve their data from some network share
as needed?

Also, will some users likely have similar or different data stored on
different workstations?


/Al
 
- backup all information stored in all user profiles on a computer to be
replaced, so that the same data will just show up in the same place on the
new workstation?

New Hardware, it is also common to see a data and share folder on the root
of the C: drive
 
Donovan Linton said:
- backup all information stored in all user profiles on a computer to be
replaced, so that the same data will just show up in the same place on the
new workstation?

Ok, but that could be tricky. If you save ALL of the contents of the
Documents and Settings folder and then restore to the new system *before*
the users login, the security settings might not be as expected. Also, there
might be conflicts with profile-related registry entries, and software that
differs ever so slightly from what is implied by the start menu.

If you simply want exactly the same image but on a new piece of hardware,
perhaps you should look into Norton Ghost or some other type of cloning
package.

/Al
 
Back
Top