Solved

WMI - VB - Pass variable to DOS Command?  Write Command Info to BAT File?

Posted on 2004-04-23
1
738 Views
Last Modified: 2013-12-03
Hi,

I need to fully automate the process that adds the machine to the domain; however, I am stuck on the last part.  Am I able to pass a variable I declared earlier in the script to the DOS Command?  Example Below:

set objWMIService = GetObject("winmgmts://" & Computer)
set objShell = WScript.CreateObject("WScript.Shell")
  objShell.Run"cmd.exe /C NETDOM ADD /d:Domain **Need to pass Variable Here (Computer Name)*** /ud:mydomain\admin /pd:password", 0, False

I already have the machine name declared previously in the program.  If this isn't possible, I am able to have this WMI script create a batchfile on the file that will write the command as test and put the proper variable in it?  

Thanks!
0
Comment
Question by:jkrech17
1 Comment
 
LVL 8

Accepted Solution

by:
Anthony2000 earned 500 total points
ID: 10924513
Have you tried:

objShell.Run"cmd.exe /C NETDOM ADD /d:Domain " & yourComputerNameVarHere & " /ud:mydomain\admin /pd:password", 0, False

I hope this helps

Anthony
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now