Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Trying to create a VB script to open Notepad with data.

$
0
0

Greetings all,

I could use some assistance with getting this script to work.  What I am trying to do is to pull the log from a remote workstation, and take that data and have it open into Notepad.

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

'Input Remote Device Name
strComputer = InputBox("Enter Name of the Remote Computer:","Prompt!")

'Make remote connection cimv2 namespace
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Run query to collect the single data file (radstate log) 
Set colFiles = objWMIService.ExecQuery _
 ("Select * From CIM_DataFile Where Name = 'C$\\Program Files (x86)\\Hewlett-Packard\\HPCA\\Agent\\log\\radstate.log'")

'Declare variables
objFileName = "radstate"
objFileExtension = "log"
strFilePath = "\\" & strComputer & "\C$\Program Files (x86)\Hewlett-Packard\HPCA\Agent\log\" & _
        objFileName & "." & objFileExtension

'Opens radstate log for reading  
Set objTextFile = objFSO.OpenTextFile(strFilePath, ForReading)
 
strContents = objTextFile.ReadAll

Dim Wsh
 
Set Wsh = WScript.CreateObject("WScript.Shell")
 
Return = Wsh.Run("Notepad.exe", 1, strContents) ' Launch Notepad.
 WScript.Sleep 800 ' Delay
   
    objTextFile.Close

 

I'll look forward to a reply.

You guys are the best!  Thanks,

Mike B.


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>