|
Hi!
I hope this is the right forum for this. I'm sorry if it isn't, please recommend a different one.
I have a .wsf written in VBScript. It gathers information about the computer it is run on and prints that out to a text document. It currently works from my computer and gathers information about my computer. However, I need to be able to run this script from any machine on the local network and retrieve the information about a server computer, which is probably just a tower in some room somewhere in another state.
SSH is out because as far as I know, SSH doesn't come preinstalled on windows and I can't assume that the computers have them; the program needs to be completely independent so I can just install it on any computer and go.
I'm running the script from a .bat file, but I think I have to change the script, not the bat file, since all the bat file does is port it to a text file.
So basically the wsf is the gist of (I just inherited this; i think it's right though because it works on my own computer):
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set CompInfo = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objComputer In CompInfo
PCName = objComputer.Name
PCDomain = objComputer.Domain
UserName = objComputer.UserName
Next
Wscript.Echo "ComputerName: " & PCName
Wscript.Echo "Domain: " & PCDomain
Wscript.Echo "UserName: " & UserName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colCSes = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objCS In colCSes
WScript.Echo "Computer Name: " & objCS.Name
WScript.Echo "System Type: " & objCS.SystemType
WScript.Echo "Number Of Processors: " & objCS.NumberOfProcessors
Next
Set colProcessors = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objProcessor in colProcessors
WScript.Echo "Manufacturer: " & objProcessor.Manufacturer
WScript.Echo "Name: " & objProcessor.Name
WScript.Echo "Description: " & objProcessor.Description
WScript.Echo "Processor ID: " & objProcessor.ProcessorID
'WScript.Echo "Address Width: " & objProcessor.AddressWidth
'WScript.Echo "Data Width: " & objProcessor.DataWidth
WScript.Echo "Family: " & objProcessor.Family
WScript.Echo "Maximum Clock Speed: " & objProcessor.MaxClockSpeed
Next
I'm sure that the first line, "strComputer = "."", needs to change from a . to the name of the computer, but how do I provide authentication? Can I just change the name to the name of the server, like hscs-gsgs or whatever, or do I need the network - networkname\hscs-gsgs? Sorry, I'm really lost.
Any help you could give would be great. Thanks in advance!
|
|
|
|
|
You can use the remote computer NetBIOS name or IP address for 'strComputer'.
If you want to run the code under different credentials, you need to use SWbemLocator:
strComputer = "192.168.1.12"
strUser = "username"
strPassword = "password"
Set objLocator = CreateObject("WBemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer, "Root\Cimv2", strUser, strPassword)
Set CompInfo = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
...
strUser needs to be an administrator account on strComputer. Firewalls can also be an issue.
|
|
|
|
|
Probably an easy question for the gang here.
I have a group box that I want to create a button at runtime. When I create the button right now, it places it 'behind' the group box instead of inside of it. How do I get the button to show up inside of the box?
Thanks in advance.
|
|
|
|
|
Nevermind, I found the answer: Me.grpQuadrant.Controls.Add(btn)
|
|
|
|
|
I have a custom control where I'd like to group a set of closely related properties. For example, look at a button control and click on the Application settings or databinding properties. There is a plus button for expanding and setting the subset properties.
How can I implement that functionality in an extended control?
Thanks!
|
|
|
|
|
|
If I am correct you will have to create a property that returns a custom made object with the properties you require. That way you can emulate the property inside a property that you describe.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
I think I found the answer in inheriting from ExpandableObjectConverter.
Thanks for the help guys.
|
|
|
|
|
|
Hi Vardhan,
If you are trying to introduce yourself, my friend this is not the right place.
Vinay
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi All
I have one application in Visual Basic.I have created one folder at runtime.I want to give permission to that folder that only administrator can access this folder,nobody can.
Is it possible in visual basic?
Second problem is:I have created runtime excel files.It works perfectly.
But problem is i want set allignment property through coding in excel file.
My code is:
Set AppXls = CreateObject("Excel.Application")
Set ObjWb = AppXls.Workbooks.Add
Set ObjWs = ObjWb.Worksheets.Add
ObjWs.Range("B1").Value = "SISTER NIVEDITA SCHOOL ON WHEELS"
ObjWs.Range("B2").Value = "SUPPORTED BY"
'ObjWs.Range("B2").Font.Bold = True
ObjWs.Range("B3").Value = "SHARE AND CARE FOUNDATION-U.S.A"
ObjWs.Range("B4").Value = "MEDICAL REPORT"
ObjWs.Range("C4").Value = Label3.Caption
ObjWs.Range("D4").Value = txt_date.Text
ObjWs.Range("B7") = Text1(0).Text
ObjWs.Range("B8") = cmb_address.Text
ObjWs.Range("B9") = Text1(2).Text
what i do?
Pls help me.
Thanks
monika
|
|
|
|
|
Hiii Monika
for the alignment in excel use the following
objws.Columns(1).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter
May this solved your problem
Thanx
~Khatri mitesh
khatrimitesh@hotmail.com
|
|
|
|
|
|
Hi,
i coded a little app. with the chart control ZedGraph and everything is working fine.
But now i have to print the chart with a background (milimeter grid).
How can manage this, is there perhaps a code snippet in the codeproject arcive ?
I really searched but i couldn't find anything !
Or are there tuts out there covering the printing with ZedGraph ?
I really don't know what i can do ;((
Many, many thanx and best regards.
Croc
|
|
|
|
|
Have you bothered to look at the ZedGraph website?
It contains alot of documentation and even a user forum, which would be the best place to ask your question.
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
is there any function in vb where you can retrieve if a specific removable drive or disk is write protected = true or false??
or any other way custom function you can retrieve its write protection state???
please...
modified on Thursday, July 24, 2008 4:30 AM
|
|
|
|
|
Maybe try writing a temporary file to the drive, if it writes it's not write-protected, if it throws an 'Access Denied' error it may be write-protected (or you don't have adequate permissions)?
|
|
|
|
|
Yup!! that's also what im thinking before.. create a temp. file if it returns permission/write protected error means false and if transaction success means true... i just got an error handling before but i've figure it out... hehe
HERE'S my sample function:
'***********start fucntion****
<br />
Private Function IsDriveWriteProtected(Byval DriveName as String) as boolean<br />
try<br />
<br />
'System.io.File.Create() statement goes here..<br />
<br />
return false<br />
catch ex as exception<br />
'if error arise? means write protected or permission to write access denied<br />
return true<br />
end try<br />
End Function<br />
'************end fucntion*******
***********Thanks to "THE JZ" ******** youre a quite good help.. and i'll mark this thread as answered in your name.. thanks again...
|
|
|
|
|
You're welcome. Glad I could help.
|
|
|
|
|
HI,
i am getting error " Word cannot fire events"
Dim oWApp As New Word.Application
oWApp.Application.Visible = True
oWApp.Application.Documents.Add()
oWApp.Selection.TypeText("Hello world")
oWApp.ActiveDocument.SaveAs("f:\vv.doc")
oWApp.Quit()
Regards,
Murali Kumar Pitchika
http://pitchika.page.tl/
http://murali.vndv.com/
Regards,
Murali Kumar Pitchika
http://muralip.f2g.net
|
|
|
|
|
Hiii
First declare object of word like this (With Events) then try.
public Withevents oWapp as new word.application
Thanx
~Khatri Mitesh
|
|
|
|
|
It took me long enough to understand the basic aspects of object orientation, like inheritance, but i still can't seem to wrap my head around what on earth an interface is or what purpose it serves. I've read all the books, and i still can't seem to get it.
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
|
|
|
|
|
Does an interface not specify the methods/functions/procedures available in the implementation section, so that you can hide the actual implementation from the users? Is it not a method of abstraction... ie: all you need to know is what to call, how to call it and what it does, you do not need to know exactly how it works.
--------------------------------------------------------
Knowledge is knowing that the tomato is a fruit.
Wisdom is not putting it in fruit salad!!
|
|
|
|
|
An interface is a "contract" that specifies what properties and methods a class must have. Interfaces are commonly used for making a program extensible. This way your program can create and use objects that implement the interface without making them inherit from a specific base class.
Another example use for interfaces is the IEnumerable interface. Anything that implements this interface can be used in for each, LINQ, and data binding. If not for interfaces, these classes would all have to inherit from the same base class. Can you imagine making Array, Stack, List, Dictionary, etc. all share a base Enumerable class?
|
|
|
|
|
Um, thanks for trying to explain it... hate to say i'm still as lost as ever. I'll think about it, see if i can't figure it out.
if (your.Life == lifestyles.Programming)
{
your.Cool = true;
}
else
{
your.Cool = false;
}
|
|
|
|