Setting script variables

Tags:
Microsoft Windows XP
I am new to Windows scripting, so please pardon the apparent simplicty of this question: From a DOS prompt, I can enter the command 'hostname' and it comes back with my computer name. How do I set that result to a script variable? Thanks.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

By default, there’s an environment variable called COMPUTERNAME which is referenced in batch files by the environment variable %COMPUTERNAME%, although I don’t know what process explicity fills out that variable.

If you use that in a batch file/script, it should be appropriate for each workstation. I’d also recommend that you open a command prompt and type set[enter] just to see the number of pre-defined environment variables that already exist. Some of them might save you some more work.

Bob

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: