DOS and VBS Syntax Reminders#

From time to time I have to break out skills from my past.  I needed to solve a few problems today that required a VBS script and a couple of batch scripts.  It took me longer than I care to admit to remember how to do this.

So, this post is a reminder for my future self.

Here's how to set a local variable in DOS and use them, as well as how to use a system environment variable (WinDir):

   1: SET INTERNAL_ROOT_PATH=D:\foo\trunk
   2:  
   3: svn.exe update %INTERNAL_ROOT_PATH%
   4: %WinDir%\Microsoft.NET\Framework\v2.0.50727\msbuild.exe %INTERNAL_ROOT_PATH%\Internal.sln /Property:Config=Release

Here is how to load an XML file into XML DOM and parse it using MSXML2 and VBScript.  This is also an example of how to Echo messages to the shell and process arguments

   1:  
   2:     path = WScript.Arguments(0)
   3:     root = WScript.Arguments(1)
   4:     
   5:     gacpath = "D:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"
   6:  
   7:     If WScript.Arguments.Count = 3 Then
   8:         gacpath = WScript.Arguments(2)
   9:     End If
  10:     
  11:     WScript.Echo WScript.Arguments.Count
  12:     WScript.Echo "Parsing LibraryManifest: " & path
  13:  
  14:     Set xml = CreateObject("MSXML2.DOMDocument")
  15:     With xml
  16:         .async = False 
  17:         .validateOnParse = False 
  18:         .preserveWhiteSpace = True
  19:         .resolveExternals = False 
  20:     End With
  21:     result = xml.load(path)
  22:  
  23:     Set moduleNodes = xml.selectNodes("//LibraryManifest/Module")
  24:  
  25:     If Not moduleNodes Is Nothing Then
  26:  
  27:         For Each moduleNode in moduleNodes
  28:             
  29:             Set assemblyNodes = moduleNode.selectNodes("Assembly")
  30:             
  31:             For Each assemblyNode in assemblyNodes
  32:             
  33:                 For Each attribute in assemblyNode.Attributes
  34:                     
  35:                     If attribute.Name = "Name" Then
  36:  
  37:                         file = root & "\" & attribute.Text
  38:  
  39:                         'WScript.Echo "file: " & file
  40:  
  41:                         Set shell = CreateObject("WScript.Shell")
  42:                         gacutil = gacpath & " -uf " & attribute.Text
  43:                         Set out = shell.Exec(gacutil)
  44:  
  45:                         Do While Not out.StdOut.AtEndOfStream
  46:                             WScript.Echo out.StdOut.ReadLine()
  47:                         Loop    
  48:  
  49:                         Set shell = CreateObject("WScript.Shell")
  50:                         gacutil = gacpath & " -if " & file
  51:  
  52:                         Set out = shell.Exec(gacutil)
  53:  
  54:                         Do While Not out.StdOut.AtEndOfStream
  55:                             WScript.Echo out.StdOut.ReadLine()
  56:                         Loop    
  57:  
  58:                         Set shell = Nothing
  59:                         Set out = Nothing
  60:  
  61:                     End If
  62:                 Next
  63:             Next
  64:         Next
  65:     End If
  66:     
8/22/2008 9:07:12 AM (Central Daylight Time, UTC-05:00) #    Comments [0]  | 

 

All content © 2008, kelly brownsberger
On this page
This site
Calendar
<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
Archives
Sitemap
Blogroll OPML
Disclaimer

Powered by: newtelligence dasBlog 1.8.5223.2

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts


Pick a theme: