• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

Need help with script


 I need assistance creating a script that will work with Windows 7 Pro x86 & x64 (or 2 different for each). I receive new laptops in the company I work for and I have to configure and add them to the domain and install standard applications. I can manually add them to the domain but the app installation process is tedious and time taking, if someone can please help me create a script to perform this task I would greatly appreciated.

for example...there are 3 different locations where the applications resides


this is an example, but in reality there are about 8 standard application on these servers to be installed per laptop.  

Thanks again!!
  • 9
  • 4
  • 2
  • +1
1 Solution
Here is what we've used for years to join PCs to the domain:

strDomain = "mydomain.LAN"
strUser = "username_with_permission_to_add_PCs_to_domain"
strPassword = "password for user account specified in strUer"

Const WIN9X_UPGRADE = 16

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strDomain & "\" & strUser, NULL, JOIN_DOMAIN + ACCT_CREATE)

Open in new window

A reboot is required to complete the process.

As for installing your apps, just create a .BAT file that contains

If I may suggest an option that removes the need for any of this: use an image
valdezfAuthor Commented:
Thanks for the fast response.

How do I write this .bat file? I don't know how to.
This cannot be used as a .BAT file; save it as a .VBS file.

Run the file from the PC that needs to be joined to the domain.
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

valdezfAuthor Commented:
but you said that I need to create a .bat file to install the software. forget about adding the laptop to the domain, that's not what I need, I need to create a batch file that would install these applications. Can anyone help me with creating this batch file for windows 7??
What commands do you currently use to install your applications?

Take the commands you run and put them in a .bat or .cmd file and run it.

Are there any prompts to your application installs?
valdezfAuthor Commented:
there are no prompts when installing these applications. I use a script that was created by my company and it works fine. The only thing I do to install these applications is click the script for that app. for example i would go to the shared drive and click a script, this will install that single application.

my request here is, how can I create 1 .bat file that can automate the installation of all these apps?

valdezfAuthor Commented:
Can someone just point me to the right direction? any tutorials or instructions I can follow on how to create a .bat file for Windows 7?
-Right Click on your desktop
-Click on NEW then Text Document (this will creat the file: New Text Document.txt
-Rename "New Text Document.txt" to: whatever.vbs
-Copy/past the script from ragnarok89 save it's content
-To run it, double click on whatever.vbs

Disclaimer: I dont know if the discussed script will work

You could also google: How install a program with a GPO

There are a lot of other way to install a program on a network PC. Have fun!

And by the way, it's the same procedure to creat a .bat file. Just call it: whatever.bat

However, if you never created a batch file before, I expect that you also may have trouble managing a server/network. Would it be possible for you to hire an IT professionnal, or you'r stuck and must figure it out by you own?


valdezfAuthor Commented:
thanks for the comment. I really don't need assistance with adding the laptops to a domain. I ONLY NEED HELP with creating a script (preferably .bat) to install some applications. I know about the extension part, I just don't know how to "write the script" for example


net use x:\\server\apps\ms office.exe"
Don't need net use.

Copy the attached code and try it in a .bat

Change the server names and such to the correct paths.

Open in new window

As an example:

This should silently install the program PXCViewer_x86.msi

-You use a domain controller named DC1
-That you want to install: PXCViewer_x86.msi
-Your logon script is a batch file

Copy "PXCViewer_x86.msi" in you NETLOGON folder

Add to your logon script:
msiexec  /q /i "\\dc1\NETLOGON\PXCViewer_x86.msi"

valdezfAuthor Commented:
this doesn't work. I've already tried it without the net use command. It will not map to the shared drive unless I use the net use command. the problem is that I might need a pause or something in between because the .exe install doesnt work with just net use x:\\server1\applications\norton.exe

valdezfAuthor Commented:
msiexec  /q /i "\\dc1\NETLOGON\PXCViewer_x86.msi" this looks promising. I will try it and post results. thanks!
You can't "net use" a file. But rather a shared folder, as of: net use x: "\\server1\applications"
valdezfAuthor Commented:
yes. I use net use to first map to the shared. this are new laptops so I need to map the shared first than install the applications.
valdezfAuthor Commented:
I found this while trying to use the msiexec. this should help me with the rest. Thanks guys!
Windows ® Installer. V 3.01.4001.5512 

msiexec /Option <Required Parameter> [Optional Parameter]

Install Options
	</package | /i> <Product.msi>
		Installs or configures a product
	/a <Product.msi>
		Administrative install - Installs a product on the network
	/j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
		Advertises a product - m to all users, u to current user
	</uninstall | /x> <Product.msi | ProductCode>
		Uninstalls the product
Display Options
		Quiet mode, no user interaction
		Unattended mode - progress bar only
		Sets user interface level
		n - No UI
		b - Basic UI
		r - Reduced UI
		f - Full UI (default)
		Help information
Restart Options
		Do not restart after the installation is complete
		Prompts the user for restart if necessary
		Always restart the computer after installation
Logging Options
	/l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
		i - Status messages
		w - Nonfatal warnings
		e - All error messages
		a - Start up of actions
		r - Action-specific records
		u - User requests
		c - Initial UI parameters
		m - Out-of-memory or fatal exit information
		o - Out-of-disk-space messages
		p - Terminal properties
		v - Verbose output
		x - Extra debugging information
		+ - Append to existing log file
		! - Flush each line to the log
		* - Log all information, except for v and x options
	/log <LogFile>
		Equivalent of /l* <LogFile>
Update Options
	/update <Update1.msp>[;Update2.msp]
		Applies update(s)
	/uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
		Remove update(s) for a product
Repair Options
	/f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
		Repairs a product
		p - only if file is missing
		o - if file is missing or an older version is installed (default)
		e - if file is missing or an equal or older version is installed
		d - if file is missing or a different version is installed
		c - if file is missing or checksum does not match the calculated value
		a - forces all files to be reinstalled
		u - all required user-specific registry entries (default)
		m - all required computer-specific registry entries (default)
		s - all existing shortcuts (default)
		v - runs from source and recaches local package
Setting Public Properties

Consult the Windows ® Installer SDK for additional documentation on the
command line syntax.

Copyright © Microsoft Corporation. All rights reserved.
Portions of this software are based in part on the work of the Independent JPEG Group.

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 9
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now