Solved

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

Posted on 2004-04-23
1
742 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

696 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