Advertisement

07.07.2008 at 09:22PM PDT, ID: 23545465
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Vbscript needs to accept alternate username and password

Asked by richrumble in VB Script, Miscellaneous Programming, VB Controls

Tags: , ,

I have the following code I'd like to execute using alternate credentials given as agumanets on the command line. I could use PsExec, runas or other such program, however that is not what I desire, ease of use be damned ;)
I currently have it accepting arguments for ip address or dns name, but I'd like it to accept user and password arguments as well, possibly across domains, so I may also need a domain argument as well, unless domain\username will work just as well.

so far, all you need is "cscript inventory.vbs 10.1.1.3" or cscript inventory.vbs 10.1.1.3 10.1.1.4 if running against more than one PC. I'd like it to be more like: cscript inventory -s ip.ip.ip.ip -u admin -p superduper password
I found the prncnfg.vbs on XP to be very close to what I want, but I couldn't make it suit, let me know if you have any questions.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
Wscript.Echo "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?>"
Wscript.Echo "<Inventory>"
Wscript.Echo 	"<Win32_Drives>"
Wscript.Echo 		"<HardDrive>"
On Error Resume Next
If Wscript.Arguments.Count = 0 Then
    arrComputers = Array(".")
Else
    Dim arrComputers()
    For i = 0 to Wscript.Arguments.Count - 1
        Redim Preserve arrComputers(i)
        arrComputers(i) = Wscript.Arguments(i)
    Next
End If
 
For Each strComputer in arrComputers
    Set objWMIService = GetObject _
        ("winmgmts:\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk Where Description = 'Local Fixed Disk'")
	For Each objItem in colItems
	    WScript.Echo "<HD_VolumeName>" & objItem.VolumeName & "</HD_VolumeName>"
	    WScript.Echo "<HD_Description>" & objItem.Description & "</HD_Description>"
	    WScript.Echo "<HD_name>" & objItem.Name & "</HD_name>"
	    WScript.Echo "<HD_DeviceID>" & objItem.DeviceID & "</HD_DeviceID>"
	    WScript.Echo "<HD_Size>" & objItem.Size & "</HD_Size>"
	    Wscript.Echo "<HD_FreeSpace>" & objItem.FreeSpace & "</HD_FreeSpace>"
	    Wscript.Echo "<HD_FileSystem>" & objItem.FileSystem & "</HD_FileSystem>"
	    Wscript.Echo "<HD_SerialNumber>" & objItem.VolumeSerialNumber & "</HD_SerialNumber>"
	    Wscript.Echo "</HardDrive>"
	Next
    Wscript.Echo "</Win32_Drives>"
    Wscript.Echo "<PC_info>"
'	Get Local Login Information
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
	For Each objItem in colItems
	    Wscript.Echo "<Caption>" & objItem.Caption & "</Caption>"
	    Wscript.Echo "<CurrentTimeZone>" & objItem.CurrentTimeZone & "</CurrentTimeZone>"
	    Wscript.Echo "<Description>" & objItem.Description & "</Description>"
	    Wscript.Echo "<Domain>" & objItem.Domain & "</Domain>"
	    Wscript.Echo "<Manufacturer>" & objItem.Manufacturer & "</Manufacturer>"
	    Wscript.Echo "<Model>" & objItem.Model & "</Model>"
	    Wscript.Echo "<Machine_Name>" & objItem.Name & "</Machine_Name>"
	    Wscript.Echo "<UserName>" & objItem.UserName & "</UserName>"
	Next
    Wscript.Echo "</PC_info>"
    Wscript.Echo "<BIOS_Info>"
'	Get Bios info, includng Dell Tag, Bios Revision and Manufacturer
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
	For Each objItem in colItems
	    Wscript.Echo "<BIOS_Version>" & objItem.BIOSVersion & "</BIOS_Version>"
	    Wscript.Echo "<BIOS_Build_num>" & objItem.BuildNumber & "</BIOS_Build_num>"
	    Wscript.Echo "<BIOS_Description>" & objItem.Description & "</BIOS_Description>"
	    Wscript.Echo "<BIOS_Manufacturer>" & objItem.Manufacturer & "</BIOS_Manufacturer>"
	    Wscript.Echo "<BIOS_Name>" & objItem.Name & "</BIOS_Name>"
	    Wscript.Echo "<Dell_Tag>" & objItem.SerialNumber & "</Dell_Tag>"
	    Wscript.Echo "<BIOS_Status>" & objItem.Status & "</BIOS_Status>"
	    Wscript.Echo "<BIOS_Version>" & objItem.Version & "</BIOS_Version>"
	Next
	    Wscript.Echo "</BIOS_Info>"
	    Wscript.Echo "</Inventory>"
Next
[+][-]07.07.2008 at 09:32PM PDT, ID: 21950906

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 09:58PM PDT, ID: 21951013

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 09:59PM PDT, ID: 21951018

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 10:05PM PDT, ID: 21951048

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 10:15PM PDT, ID: 21951077

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.07.2008 at 10:34PM PDT, ID: 21951146

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Miscellaneous Programming, VB Controls
Tags: vbscript, vbs, vbscript accept external aguments
Sign Up Now!
Solution Provided By: RobSampson
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.08.2008 at 03:37AM PDT, ID: 21952408

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.08.2008 at 03:59PM PDT, ID: 21959152

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628