Questions

VB script error

+
0 Votes
Locked

VB script error

nmaharaskal
'-=-=-=Create Folder=-=-=-=-=-

Dim oShell, oEnv, oFS, strDirectory

Set oShell = CreateObject("wscript.Shell")
set oFS = CreateObject("scripting.FileSystemObject")
Set oEnv = oShell.Environment("Process")

strDirectory = oEnv("USERPROFILE") & "\Desktop\VBSLab"
if not oFS.FolderExists(strDirectory) then oFS.CreateFolder(strDirectory)

'-=-=-==-=-=-=-=Retrive sysinf0 & save in txt n open the file =-=-=-=-=-=

Set FSO = CreateObject("Scripting.FileSystemObject")

Set TextFile = FSO.OpenTextFile(strDirectory & "\SysInfo.txt", 2, True)
Dim Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
TextFile.Writeline "OS Name: " & objOperatingSystem.Name
TextFile.Writeline "Version: " & objOperatingSystem.Version
TextFile.Writeline "OS Manufacturer: " & objOperatingSystem.Manufacturer
TextFile.Writeline "OS Name: " & objOperatingSystem.SizeStoredInPagingFiles
Next
Set TextFile = Nothing
Set FSO = Nothing

Wsh.Run strDirectory & "\SysInfo.txt", 1, True ' Error on this line kindly assist me pls.
WScript.Sleep 800 ' Delay allows Notepad to get the focus.
  • +
    0 Votes
    nmaharaskal

    I found the solution already.

    On Error Resume next
    Wsh.Run Chr(34) & strDirectory & "\SysInfo.txt" & Chr(34)'Open the SysInfo.txt

  • +
    0 Votes
    nmaharaskal

    I found the solution already.

    On Error Resume next
    Wsh.Run Chr(34) & strDirectory & "\SysInfo.txt" & Chr(34)'Open the SysInfo.txt