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.
VBScript Error
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.
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.
- maharaskal
- Posts: 3
- Last visit: Sun May 27, 2012 8:00 pm
VBScript Error
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.
'-=-=-=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.
- maharaskal
- Posts: 3
- Last visit: Sun May 27, 2012 8:00 pm
VBScript Error
i found the solution.
On Error Resume next
Wsh.Run Chr(34) & strDirectory & "SysInfo.txt" & Chr(34)'Open the SysInfo.txt
On Error Resume next
Wsh.Run Chr(34) & strDirectory & "SysInfo.txt" & Chr(34)'Open the SysInfo.txt