BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
| |
 |
 |
 |
 |
 |
| VB Script for Running the SMS Remote Tools |
 |
|
|
By: Rod Trent
Posted On: 7/24/2001
Submitted by Joelle M. Booher; developed by Dave Kindness
Basic rules:
- Make sure the SMSAdmin Console is already installed on the machine
- Edit the script to change the path to the SMSAdmin Console directory if it differs from the default
- Put the VBS script into the smsadmin\i386\bin directory
- If you use a shortcut, it needs to start in the smsadmin\i386\bin directory
- Existence of c:\temp is assumed
Copy and paste the following script (between the lines) into Notepad, making sure to have Word Wrap disabled, then save it with a .vbs extension.
================================== Option Explicit
Dim oArgs Dim oWshShl ' Shell Object Dim sNetbiosName Dim oF ' File Object Dim oFs ' File system object dim x, gotit, badip, address dim rc
Const ForReading = 1, ForWriting = 2, ForAppending = 3 const RemoteExe = "C:\SMSADMIN\bin\i386\remote.exe"
' First check to see if remote.exe is in this directory
on error resume next Set oFs = CreateObject("Scripting.FileSystemObject") ' get handle to file interface Set oF = oFs.getFile(Remoteexe) if err.number <> 0 then wscript.echo "Error! Could not find " & RemoteExe wscript.quit end if set of = nothing ' release object ' If no server name on command line, ask the user for one Set oArgs = WScript.Arguments ' get command line arguments if oargs.count = 0 then sNetbiosName = InputBox("Please enter the machine name.","SMS 2.0 Remote Control Launcher") if sNetbiosName = vbNullString then WScript.Quit() End If else sNetbiosName = oArgs(0) ' first arg is server name end if
' See if we can ping the name
set oWshShl = wscript.createobject("wscript.shell") ' get handle to shell object rc = oWshShl.run ("cmd /c ping -n 1 " & sNetbiosName & " > c:\temp\~smsview.txt",0,true) ' run lookup
' Now read in the information
Set oF = oFs.opentextFile("c:\temp\~smsview.txt",forreading) gotit = 0 badip = 0 Do While oF.AtEndOfStream <> True x = oF.readline if instr(x, "Bad IP address") > 0 then badip = 1 end if if instr(x, "Reply from") > 0 then address = trim(mid(x,12)) address = mid(address,1,instr(address,":") - 1) gotit = 1 end if loop oF.close ' close temp file Set oF = oFs.getFile("c:\temp\~smsview.txt") of.delete ' delete it
' If we found a valid address, launch the remote tools program
if gotit = 1 then wscript.echo "Launching remote.exe 2 " & address rc = oWshShl.run ("C:\SMSADMIN\bin\i386\remote.exe 2 " & address ,1,false) elseif badip = 1 then wscript.echo "No IP address was found for " & sNetbiosName else ' Report the existence of a DNS entry so that NIS can be cleaned up wscript.echo sNetbiosName & " has a DNS entry, but it did not respond to PING." end if
wscript.quit ==================================
NOTE: Make sure you have the latest scripting engines on the workstation you run this script from. Download the latest scripting engines here: http://msdn.microsoft.com/scripting/
For scripts that interact with the file system, you can learn more about the file system object (fso) from Microsoft's FileSystemObject User's Guide: http://msdn.microsoft.com/scripting/vbscript/doc/jsFSOTutor.htm
|
 |
 |
 |
|
|