Jump to content

can i have a little help with a vbs script please?


Recommended Posts


Just a couple of things to report on first run,

'Logon On Name' should say Logon Name

Both the Logon Name and 'Computer Name' would be better in their original character case, not upper case.

Link to comment
Share on other sites

Yzöwl

Thank you for this 'Logon On Name' should say Logon Name

I thought I had it as Logon Name. :no:

Did you have any suggestion as to what else could be added or removed?

If any one else would like to add to this project please post a script or suggestion. I give credit inside a comment line in the HTA

      <!-- HTA and VBS scripts by Gunsmokingman

Credits for helping with the VBS scripts

WMI Bios Class By RoqueSpear Re-Edit By Gunsmokingman

WMI Ram Memory BY Eyeball Re-Edit By Gunsmokingman

Spelling and Layout of the VBS format By Cluberti

Spelling and Layout Suggesion Yzöwl

Original Idea by Eyeball

-->code]

I have made the changes that Yzöwl pointed out and the V3 version has been updated.

Updated HTA SFX [color=#000099]SystemReport_V3[/color]

Edited by gunsmokingman
Link to comment
Share on other sites

I was wondering if I should add this script to the HTA it to list services that are installed on the computer.

This makes a text file then it runs it then it deletes it.

Save as ListService.vbs

' // ---> VARIBLES 
Dim strComputer : strComputer = "."
Dim Ln1, S_3, S_5, V : V = vbCrLf
S_5 = Space(5) : S_3 = Space(3) : Ln1 = Chr(171) & " --------------------------------- " & Chr(187)
Ln1 = S_3 & Ln1
Dim colSvc, Cnt, obj1, obj2, obj3, objAuto, ObjDisable, ObjList, ObjManual, objSvc, SvcRpt
' // ---> OBJECTS
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2")
Set colSvc = objWMI.ExecQuery ("SELECT * FROM Win32_Service")
' // ---> LOOP WMI SERVICE CLASS
For Each objSvc in colSvc
SvcRpt = (_
S_5 & "Name : " & objSvc.DisplayName & V &_
S_5 & "Start Mode : " & objSvc.StartMode & V &_
S_5 & "ServiceType : " & objSvc.ServiceType & V &_
S_5 & "Path To Name : " & objSvc.PathName & V &_
S_5 & "Status : " & objSvc.State & V &_
S_5 & "Process Id : " & objSvc.ProcessId & V &_
S_5 & "Desktop Interact : " & objSvc.DesktopInteract & V &_
S_5 & "Accept Pause : " & objSvc.AcceptPause & V &_
S_5 & "Accept Stop : " & objSvc.AcceptStop & V & Ln1 & V) '&_
' S_5 & "Description : " & objSvc.Description & vbCrLf &"---------------" & vbCrLf )
' // ---> AUTOMATIC SERVICE
If InStr(objSvc.StartMode,"Auto") Then
obj1 = obj1 + 1
objAuto = objAuto & S_5 & "Automatic Service" & V & SvcRpt
End If
' // ---> MANUAL SERVICE
If InStr(objSvc.StartMode,"Manual") Then
obj2 = obj2 + 1
If objSvc.Started = True Then
' // ---> MANUAL SERVICE IF RUNNING
ObjManual = ObjManual & S_5 & "This Service Is Running" & V & SvcRpt
Else
' // ---> MANUAL SERVICE IF NOT RUNNING
ObjManual = ObjManual & S_5 & "This Service Is Not Running" & V & SvcRpt
End If
End If
' // ---> DISABLE SERVICE
If InStr(objSvc.StartMode,"Disabled") Then
obj3 = obj3 + 1
ObjDisable = ObjDisable & S_5 & "Disable Service" & V & SvcRpt
End If
Next
' // ---> FOR THE TOTAL AMOUNT OF AUTO, DISABLE, MANUAL SERVICE NUMBER
Cnt = obj1 : Cnt = Cnt + obj2 : Cnt = Cnt + obj3
' // ---> BUILDS THE INFORMATION
ObjList = S_5 & "Total Amount Of Installed Services : " & Cnt & V & Ln1 & V & V
ObjList = ObjList & S_5 & "Total Amount Of Automatic Services : " & obj1 & V & Ln1 & V &_
V & objAuto & V & Ln1 & V
ObjList = ObjList & S_5 & "Total Amount Of Manual Services : " & obj2 & V & Ln1 & V &_
V & ObjManual & V & Ln1 & V
ObjList = ObjList & S_5 & "Total Amount Of Disable Services : " & obj3 & V & Ln1 & V &_
V & ObjDisable & V & Ln1 & V
' // --->
' // ---> VARIBLES
Dim Act, Fso, ListSvc, Ts
' // --->
' // ---> OBJECTS
Set Act = CreateObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
ListSvc = Act.ExpandEnvironmentStrings("%SystemDrive%\ListService.txt")
' // --->
' // ---> TEXT FILE OUTPUT
Set Ts = Fso.CreateTextFile(ListSvc)
Ts.WriteLine ObjList
Ts.Close
' // ---> RUN THE TEXT FILE THEN DELETS THE TEXT FILE
Act.Run(ListSvc),1,True : Fso.DeleteFile(ListSvc),True

Link to comment
Share on other sites

ner is right, it does display only the code in a window but on on windows 2000. when i get back to work im going to try running it from a win 2k3 server on a win 2k server and see if it works that way.

that services script is neat! wouldnt really need it in the .hta tho unless it was an optional thing, maybe part of the drop down that could be enabled? or in the hta output like the defrag button

Link to comment
Share on other sites

I have made the changes that Yzöwl pointed out and the V3 version has been updated.

Link to SystemReport_V3 Updated

It's still exactly the same GSM!

Anyhow, in the mean time here's a version I've been messing with. It basically contains all the missing elements I could find, and there were hundreds of them.

  • </B><TR></TR></TABLE></BODY>

I removed unnecessary entries, in the javascript code, and changed other minor things such as <script LANGUAGE=VBScript> for <script TYPE="text/vbscript"> and the formatting.

SystemReportV3.exe

Link to comment
Share on other sites

The functionality etc. hasn't changed, just the correctness of the code, <TR> tags should have, but weren't used, all the <B> tags remained unclosed, there were some incorrect and many missing tags. They were'nt noticed, previously due to the forgiving nature of HTML. In the javascript for the cleanup and defrag routines, the same function was declared twice in two cases. If you were to keep the %computername%.hta, change its extension to html, and run it through a HTML code checker, you'd see the differences in the two versions, otherwise you shouldn't.

The code isn't mine, and as such I wouldn't change its functionality, I hope this helps explain a little better.

Link to comment
Share on other sites

Yzoxl It nice that you have tooken an intrest in this but

1:\ <TR> </TR> I do not use them, and are not needed as this a HTA and it standard are diffent then HTML.

2:\ I did update the V3 sfx file

Image One

Image Two

I do not know what happen with that other then I did update the SFX files with what you suggested

3:\ Looking at your code I got lost because It hard for me to read things in that format. It would be easy for me to miss > or < or a " : ; in that format, never mind trying to write it like that, I have tried it that way because it does look cool, but it blends it self so i have loose my focus. Until I was around 14 or 15 a word that began with W look the same to me So World look the same as What, I had to read the word before and after to fgure out the word. Now this does not happen to me as much I still have problem like that with reading and writing.

4:\ Since this can go to the right until it maximum length and in notepad2 it stops at 118 which is not that long of a line of code. If the HTA was less then 100 lines, then it would look like your but at over 800 I utilized the left to right not to mention it easier for me to read

/* EXPANDS MENUS */  
function expand(s)
{var td = s;var d = td.getElementsByTagName("div").item(0);td.className = "menuHover"; d.className = "menuHover";}

function expand(s) {
var td=s;
var d=td.getElementsByTagName("div").item(0);
td.className="menuHover";
d.className="menuHover";
}

5:\ If you want I will send you the CSS and you can edit that to the format that you write, as it will be external in the next version, I have faith in your coding, and I do not have to look at it, I will end up with errors doing it that way.

6:\ I like the fact that you want to help and participate in this project, but please understand that when you say hundreds of errors for thing that are not needed and it is written correct or it would not work. The one you wrote works no diiferent then the one I wrote, the only difference is mine is almost 300 lines smaller then yours, plus there is a difference on the size. MSN COM Source Code

Your Edit File Size 48.6 KB extracted from the SFX

My File Size 44 KB extracted from the SFX.

Thank you for the heads up on the js I could not even see the errrors in it until I made a script to output it, to a js file. Even then it was hard for me to see it.

Edited by gunsmokingman
Link to comment
Share on other sites

I have to disagree GSM, since your output file does not contain the <HTA:APPLICATION> tag, it is essentially a HTML file and as such should follow its rules. The format, as I said previously, is down to individual tastes, (I made changes to the js file too). I only changed the format to suit my own preference so that it would enable me to follow the code sufficiently to make my changes. Also, if file size was an issue, since it runs straight from an exe, I'd have improved the compression of the archive.

[Edit]

So as not to overload an excellent thread and detract focus from your application, I have decided to edit and use a previous message to further explain my point.

HTA is a HTML Application, it should therefore as much as possible follow the standards laid down for HTML. You have decided differently and your HTA has not suffered noticably as a consequence. As far as I'm concerned in HTML, which as I've said before, we are working in, if tags are not closed, of which there were hundreds in the final output then that is strictly speaking a coding error.

Also if my output was to HTML as opposed to HTA, which I've tried with my version only, it works fine without error or popup or warning. (I dont have an IE engined browser assigned to HTML documents). The only difference is that the background is a nasty looking red colour.

In closing, I dont think that because something has a forgiving nature, that nature or trait should be tested. Just because a person may be good at coping with pressure, doesn't mean that we should strive to put them under it.

[/Edit]

Edited by Yzöwl
Link to comment
Share on other sites

It the actual HTA outside of the SFX, that differs in size. HTA is ment to run from a desktop enviroment so it a lot more forgiving on processing the script. Try a HTML from a desktop and you will get a warning about it and a alllow to run dialog. The tag does not have to be there for a HTA. Check the one that get made, by the script I have no tag for it.

Here is a quote from the HTA Developers Center

Creating Your Own HTAs: The First of a Multi-Part Tutorial

The <HTA:Application> Tag

You can actually create an HTA without using the <HTA:Application> tag; your HTA will run just fine and there will be no change in functionality or performance.

So if you don’t have to use the <HTA:Application> tag then why would you ever want to use it? (Hmmm, when you put it that way you sound remarkably like one of the teenage Scripting Sons.…) Well, the <HTA:Application> tag provides you with the ability to control the appearance of your HTA window; this is done by configuring the various tag properties. Here’s the <HTA:Application> tag used in our sample script:

I have to agree with you about taste, but for me it easier to work with some that looks like sentence. As I said it will cause me to loose focus if I have to look 4 or 5 lines downward while looking left to right.

On the Js I do thank you for that because I could not see any thing that was double so I did miss it. As I said Yzöwl I have complete faith in what ever you script, your cmd scripts are a good example of the excellent work you do and I believe you apply that quality in other script languages.

Link to comment
Share on other sites

Thanks for posting your version 3, however this does not seem to work. When you run the exe all you see is the prgramming code/script?

I have made some changes to this HTA. This when completed will work on these Operating Systems, W2K, XP, W3K, Vista. The reason I have change the layout is because the WMI classes that work on XP may not work on W2K, W3K, Vista, that is why the he had problems and it would not work. The new layout is almost finish. The new HTA has 5 different sections, they are the Main Menu, W2K, XP, W3K,Vista. The image below show the new layout, the text that appears will not be there, it there so I can direct the output there when the script runs, so they are just makers. I am now going threw to make sure each class works so this will take a couple of days, I hope you like then new layout. When finish the main menu will have only text on it with the what the script will scan for and on what Operating Systems.

ComputerInfo_Layout.PNG

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...