Solved

Need help with script

Posted on 2011-03-23
18
518 Views
Last Modified: 2012-05-11
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
Comment
Question by:valdezf
  • 9
  • 4
  • 2
  • +1
18 Comments
 
LVL 8

Expert Comment

by:ragnarok89
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
Thanks for the fast response.

How do I write this .bat file? I don't know how to.
0
 
LVL 8

Expert Comment

by:ragnarok89
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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
 
LVL 21

Expert Comment

by:AmazingTech
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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
 
LVL 10

Expert Comment

by:ReneGe
Comment Utility
-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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 10

Expert Comment

by:ReneGe
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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
 
LVL 21

Expert Comment

by:AmazingTech
Comment Utility
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
 
LVL 10

Accepted Solution

by:
ReneGe earned 500 total points
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
msiexec  /q /i "\\dc1\NETLOGON\PXCViewer_x86.msi" this looks promising. I will try it and post results. thanks!
0
 
LVL 10

Expert Comment

by:ReneGe
Comment Utility
You can't "net use" a file. But rather a shared folder, as of: net use x: "\\server1\applications"
0
 

Author Comment

by:valdezf
Comment Utility
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
 

Author Comment

by:valdezf
Comment Utility
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now