Version: 13.1a
Revision: 15 Build 16
VBScript – redirect WSscript into any directory
Introduction: yesterday, from work, I was totally boiling! This made everyone in the department a little curious…they aren’t sure, what happened.
But, that is not the point about this article…
This article will help user and IT administrator handle “wscript output” into any directory.
So, the solution is pretty much…simple…plain stupid. All we need to do is use: “AddQuotes, StringInput and stringRun” to accomplish this process. However, this will only work on “Windows XP SP2 +”, and, to avoid confusion, please read VBScript for dummies…
Bah…here is the Script! I need to get on with my Novel. But, don’t panic and run off my blog, I am just stressed. That is all…
——————————————
Notes #1: the function “AddQuotes” takes care of the double quoting issues, by surrounding whatever input (using the “stringInput” argument of the AddQuotes function.), and redirect the commands, using the built in “Chr(34)” function.
Notes #2: for the “%compspec% /c syntax”. That is old school and it’s already shown in Microsoft KB Articles.
—Copy Source Code—
'Author: Lair360
'Version: 13,6a
'Revision: 14.1 Build 11
'---------------------------------
Set objShell = WScript.CreateObject("WScript.Shell")
'You can modify this line only. But, don't modify anything else below "StrRun".
'---------------------------------
strRun = "%comspec% /c ipconfig.exe > " & AddQuotes("C:\temp\ipconfig.txt")
'---------------------------------
objShell.Run strRun, 1, True
Function AddQuotes(strInput)
AddQuotes = Chr(34) & strInput & Chr(34)
End Function
—End Source Code—
Here is another version for you to analyze. But, don’t get too confuse about it…
—Copy Source Code—
'Author: Lair360
'Version: 13,6a
'Revision: 14.1 Build 11
'---------------------------------
On Error Resume Next
Set objShell = WScript.CreateObject("WScript.Shell")
'You can modify this line only. But, don't modify anything else below "StrRun".
'---------------------------------
strRun = "%comspec% /k c: & ipconfig /displaydns > " & AddQuotes("I:\vbs project\ipconfig.txt")
'---------------------------------
objShell.Run strRun, 1, True
Function AddQuotes(strInput)
AddQuotes = Chr(34) & strInput & Chr(34)
End Function
—End Source Code—
Copyrighted By Lair360







