?
Solved

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

Posted on 2004-04-23
1
Medium Priority
?
743 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Anthony2000 earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

777 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