Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-27-2012, 10:18 PM
maharaskal maharaskal is offline
Registered User
 
Join Date: May 2012
Posts: 1
VBScript Error

Error on path, i have remark the error line kindly assit me pls

'-=-=-=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.
Reply With Quote
  #2  
Old 05-28-2012, 10:06 AM
miked's Avatar
miked miked is offline
Registered User
 
Join Date: Feb 2004
Posts: 2,039
Hello maharaskal,

You mentioned an error on directory. What is the error message you are seeing?

Can you MsgBox strDirectory?

Are you trying to open the text file Sysinfo.txt in Notepad.exe?
__________________
Mike
VanDyke Software
Technical Support
[http://www.vandyke.com/support]
Reply With Quote
Reply

Tags
vbscript

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:14 PM.