VBScript Error

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
maharaskal
Posts: 3
Last visit: Sun May 27, 2012 8:00 pm

VBScript Error

Post by maharaskal »

Hi guys its giving error on the path. kindly assist me on this. thanks in advance.

'-=-=-=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") & "DesktopVBSLab"
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("%USERPROFILE%") & "desktopvbslabSysInfo.txt", 2, True) ' Error at here
Dim Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
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 ("%USERPROFILE%") & "desktopvbslabSysInfo.txt", 1 ' Another Error at here also.
WScript.Sleep 800 ' Delay allows Notepad to get the focus.
User avatar
maharaskal
Posts: 3
Last visit: Sun May 27, 2012 8:00 pm

VBScript Error

Post by maharaskal »

Hi guys its giving error on the path. kindly assist me on this. thanks in advance.

'-=-=-=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") & "DesktopVBSLab"
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("%USERPROFILE%") & "desktopvbslabSysInfo.txt", 2, True) ' Error at here
Dim Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
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 ("%USERPROFILE%") & "desktopvbslabSysInfo.txt", 1 ' Another Error at here also.
WScript.Sleep 800 ' Delay allows Notepad to get the focus.
User avatar
maharaskal
Posts: 3
Last visit: Sun May 27, 2012 8:00 pm

VBScript Error

Post by maharaskal »

i found the solution. :)
On Error Resume next
Wsh.Run Chr(34) & strDirectory & "SysInfo.txt" & Chr(34)'Open the SysInfo.txt
This topic is 11 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked