VB script to output %windir% to text file

Associate
Joined
17 Nov 2006
Posts
123
Location
Manchester
Hi guys, I've currently been tasked with writing a VBscript that we can run as part of a users login script or distribute via a NAL object through Zenworks.

Basically I'm looking for a simple script that will determine what the Windows Directory is (e.g C:\WINDOWS, C:\WINNT) using the %windir% variable and IF C:\WINNT export the results to a text file.

So far, Ive come up with the following,

Code:
set shell = WScript.CreateObject("WScript.Shell")
windowsdir = shell.ExpandEnvironmentStrings("%windir%")
MsgBox(windowsdir)

Which displays the result in a popup window, instead I'd like the result to be saved as a text file IF the answer is C:\WINNT.

Any help would be greatly appreciated.
Thanks.
 
Thanks for the reply, but I'm looking more towards an IF statement.
Such as,
if 'directoryname' exists outout to a text file.
 
Cheers for the help, all sorted. I also added a new variable which outputs the computer's hostname to save some time, and have used a simple VB script to call the batch file.
 
Back
Top Bottom