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

Need help with script

Hello,

 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

\\server1\applications\Norton.exe
\\server2\installations\MSoffice.exe
\\server3\approved\adobeAcrobat.exe

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

Thanks again!!
0
valdezf
Asked:
valdezf
  • 9
  • 4
  • 2
  • +1
1 Solution
 
ragnarok89Commented:
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 JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144


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
\\server1\applications\Norton.exe
\\server2\installations\MSoffice.exe
\\server3\approved\adobeAcrobat.exe


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

How do I write this .bat file? I don't know how to.
0
 
ragnarok89Commented:
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.
0
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??
0
 
AmazingTechCommented:
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?
0
 
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?


0
 
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?
0
 
ReneGeCommented:
-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!

Cheers,
Rene
0
 
ReneGeCommented:
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?

Cheers,
Rene

0
 
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

"@ ECHO

net use x:\\server\apps\ms office.exe"
0
 
AmazingTechCommented:
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.
\\server1\applications\Norton.exe
\\server2\installations\MSoffice.exe
\\server3\approved\adobeAcrobat.exe

Open in new window

0
 
ReneGeCommented:
As an example:

This should silently install the program PXCViewer_x86.msi

Assumptions:
-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"

0
 
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

0
 
valdezfAuthor Commented:
msiexec  /q /i "\\dc1\NETLOGON\PXCViewer_x86.msi" this looks promising. I will try it and post results. thanks!
0
 
ReneGeCommented:
You can't "net use" a file. But rather a shared folder, as of: net use x: "\\server1\applications"
0
 
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.
0
 
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
		Quiet mode, no user interaction
	/passive
		Unattended mode - progress bar only
	/q[n|b|r|f]
		Sets user interface level
		n - No UI
		b - Basic UI
		r - Reduced UI
		f - Full UI (default)
	/help
		Help information
Restart Options
	/norestart
		Do not restart after the installation is complete
	/promptrestart
		Prompts the user for restart if necessary
	/forcerestart
		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
	[PROPERTY=PropertyValue]

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

0
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