Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

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.  …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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