Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript to specifically change Windows XP environment variable 2

Status
Not open for further replies.

geranimo666

Technical User
Sep 19, 2006
195
US
Hello all-

I didn't know that in Windows XP you can't just use the ping or ipconfig commands if you simply drop to a command prompt. You must first change the path to c:\windows\system32 in order to do so. I check the environment variable that is set for %comspec% and it's c:\windows\system32.. I have users across my entire building that have xp which is not a big deal for the user but if a technician needs to get to any of these machines, they'd need to change to that path in order to ping, ipconfig etc. Is there a vbscript I could run within a GPO or login script that somehow modifies this?

This was never a problem in Windows 2000 Pro as long as you typed cmd from Start/Run.. you could use these commands. Perhaps I'd need the script to copy these two exe's ping and ipconfig to the root c: drive instead?

If anyone has any ideas, I would be greatful indeed!!
geranimo
 
YES! Mr.Mov!!

This did it..

A star for you determined soul

geranimo
 
One question..

where you state the cscript part.. where it says /username:system

Do you just need to place the domain account user name or does it also need the hostname of the pc i.e- /mgeranimo:COMPUTER1

thanks
geranimo
 
sorry geranimo666, i thought that might be misleading.
as you can see from the script one of the Win32_Environment properties is called 'UserName'. This refers to strings of <SYSTEM> or <USER> which, i guess, means if the environment variable is computer (i.e. all users get it) or user specific...so start the script with

/username:SYSTEM or USER
 
'below from the docs, so, either SYSTEM or the actual user...perhaps i should update the script so that if someone passes in /username:USER then it converts "USER" to the currently logged on user WshShell.ExpandEnvironmentStrings("%username%")...but i will leave that to you :)

UserName
Data type: string
Access type: Read/write
Qualifiers: Key, MaxLen(260)
Name of the owner of the environment setting. It is set to <SYSTEM> for settings that are specific to the Windows system (as opposed to a specific user) and <DEFAULT> for default user settings.

Example: "JSmith"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top