23. maj 2007 - 21:32
Der er
3 kommentarer og 1 løsning
Informationer skrevet ud til fil istedet for messageboxe
Hej, Jeg kunne godt tænke mig at få mine output-resultater skrevet ud til en fil, f.eks. rtf eller lign. istedet for de kommer ud i "message-bokse". Kan det lade sig gøre ? vh thjoe f.eks. dette: ' List Operating System and Service Pack Information ' Windows Server 2003 : Yes ' Windows XP : Yes ' Windows 2000 : Yes ' Windows NT 4.0 : Yes ' Windows 98 : Yes strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOS in colOSes Wscript.Echo "Computer Name: " & objOS.CSName Wscript.Echo "Caption: " & objOS.Caption 'Name Wscript.Echo "Version: " & objOS.Version 'Version & build Wscript.Echo "Build Number: " & objOS.BuildNumber 'Build Wscript.Echo "Build Type: " & objOS.BuildType Wscript.Echo "OS Type: " & objOS.OSType Wscript.Echo "Other Type Description: " & objOS.OtherTypeDescription WScript.Echo "Service Pack: " & objOS.ServicePackMajorVersion & "." & _ objOS.ServicePackMinorVersion Next
Annonceindlæg fra Infor
Hey ! Dette script fyrer det ind i filen angivet son fil : ' List Operating System and Service Pack Information ' Windows Server 2003 : Yes ' Windows XP : Yes ' Windows 2000 : Yes ' Windows NT 4.0 : Yes ' Windows 98 : Yes fil = "c:\users\morten\documents\data.txt" const ForWriting = 2 set fso = createobject("scripting.filesystemobject") strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOS in colOSes strtekst = strtekst & "Computer Name: " & objOS.CSName & vbcrlf strtekst = strtekst & "Caption: " & objOS.Caption & vbcrlf 'Name strtekst = strtekst & "Version: " & objOS.Version & vbcrlf 'Version & build strtekst = strtekst & "Build Number: " & objOS.BuildNumber & vbcrlf 'Build strtekst = strtekst & "Build Type: " & objOS.BuildType & vbcrlf strtekst = strtekst & "OS Type: " & objOS.OSType & vbcrlf strtekst = strtekst & "Other Type Description: " & objOS.OtherTypeDescription & vbcrlf strtekst = strtekst & "Service Pack: " & objOS.ServicePackMajorVersion & "." & _ objOS.ServicePackMinorVersion Next set ts = fso.opentextfile(fil,ForWriting,1) ts.write strtekst ts.close /killer
Kanon. Lige det... takker og bukker. PS. Kan scriptet slutte af med at åbne filen ?
Velbekomme, og ja : (Det er kun sidste linie, der skal tilføjes :o) ) ' List Operating System and Service Pack Information ' Windows Server 2003 : Yes ' Windows XP : Yes ' Windows 2000 : Yes ' Windows NT 4.0 : Yes ' Windows 98 : Yes fil = "c:\users\morten\documents\data.txt" const ForWriting = 2 set fso = createobject("scripting.filesystemobject") set shell = wscript.createobject("wscript.shell") strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOSes = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOS in colOSes strtekst = strtekst & "Computer Name: " & objOS.CSName & vbcrlf strtekst = strtekst & "Caption: " & objOS.Caption & vbcrlf 'Name strtekst = strtekst & "Version: " & objOS.Version & vbcrlf 'Version & build strtekst = strtekst & "Build Number: " & objOS.BuildNumber & vbcrlf 'Build strtekst = strtekst & "Build Type: " & objOS.BuildType & vbcrlf strtekst = strtekst & "OS Type: " & objOS.OSType & vbcrlf strtekst = strtekst & "Other Type Description: " & objOS.OtherTypeDescription & vbcrlf strtekst = strtekst & "Service Pack: " & objOS.ServicePackMajorVersion & "." & _ objOS.ServicePackMinorVersion Next set ts = fso.opentextfile(fil,ForWriting,1) ts.write strtekst ts.close shell.run fil
Fedt... Og endnu engang tak.
Kurser inden for grundlæggende programmering