# Solved: VBScript to Install Software



## Davecann2 (Feb 9, 2012)

Hi All,

I am a complete beginner creating VB scripts and could use your guidance. I want to create a logon script, launched by GPO, that will install an msi file. My dilemma is that the user does not have permissions to perform installs.

Is there a way to include a username and password within the code to allow the install? This is what I have so far...


```
Const ALL_USERS = True
Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("Software.msi", , ALL_USERS)
```
... Any help that you can provide is greatly appreciated! thx


----------



## Ent (Apr 11, 2009)

I would imagine that it's possible, but suggest that it's not wise. Essentially you'd be passing the username and password of an administrator account in plain text format (scripts are plain text) over the network, and that's a massive security don't-do.


----------



## Davecann2 (Feb 9, 2012)

Thank you for your reply...and I completely agree that it is a security risk.

I'm open to alternatives? =)


----------



## Ent (Apr 11, 2009)

Isn't the obvious option just to go around and install the software ready for the users? 

Failing that, I believe (although I've never used it) that group policy startup scripts (not logon scripts) run as the administrator level SYSTEM user.


----------



## Cobra35y (Sep 19, 2012)

do you have the software package on a server or share drive, if so give the user account permissions to the share drive specifically for these GPO's to be pushed and installed... not for sure i would have to test on my network setup with our server something similar, but the GPO should apply a runonce policy and you should probably have a script locally pushed to each computer that is static or on standby until called by the GPO push to get the file from the share and have the local script have admin privililiges or read and write access to the share so it can copy it to each local computer or install over network, however if you write the script to copy from share to local it will take less time to install and won't be interupted, plus you can have your script check to see if certain files exist at location and copy all or certain .msi files and install them sequentially with a wait command to wait for first install to finish before executing sequential installations...

is that where your going with this or am i missing parts?


----------



## Cobra35y (Sep 19, 2012)

this is something i use but it allows the user to do the install andits a batch file. might help in getting you in "a" direction or give you other ideas for implementation. you can set this to be called by startup script or task scheduler or change it to fit all installs in a specific share folder....


```
@echo off
Title HOST: Installing Updates on %computername%
[COLOR=red]set server=\\SERVERNAME or PATH\msifolder[/COLOR]
:select
cls
echo Select one of the Following MSI Install Folders for installation task.
echo.
dir %server% /A:D /B
[COLOR=red]SET /P MSI=Please enter the MSI Folder to install: [/COLOR]
[COLOR=red]SET source=%server%\%MSI%[/COLOR]
echo Selected Installation %MSI%
echo.
echo.
 
:verify
ECHO Is This Correct?
echo.
echo.
ECHO 0: ABORT INSTALL
ECHO 1: YES
ECHO 2: NO,RE-SELECT
SET /p choice=Select YES, NO or ABORT? [0,1,2]:
     if /i [%choice%]==[0] endlocal&goto end
     if [%choice%]==[] goto BCurrentlocal
     if [%choice%]==[1] goto yes
 if [%choice%]==[2] goto no
 endlocal
 
:no
goto select
:yes
[COLOR=red]set FILENAME=%MSI%[/COLOR]
[COLOR=red]call %source%\%FILENAME%.msi[/COLOR]
[COLOR=red]echo beginning %MSI% installation[/COLOR]
pause
echo Exiting Install Script....
PING -n 4 127.0.0.1 >nul
exit
```


----------



## Davecann2 (Feb 9, 2012)

Hi All,

Thank you so much for replying to my post. You have all giving me something to think about! I really appreciate your input and I am sure it will point me in the right direction! 

Best,
Dave


----------



## Cobra35y (Sep 19, 2012)

No problem. i know the headache of having over 100 systems to push installs to and to "go around and install" that may be fine and a better solution for small office or computer lab but then no one is learning how to program or script in turn not maximizing their time towards other duties or even more off time. plus if you can put a few hours in and make something that can potentially be reused or slightly modified for the next time, your making yourself and your network more efficient. 

Let us know what you get to work best for you, so we know what was a better option or route to take and help others in your situation.


----------



## Ajunar (Sep 22, 2012)

The vbs script to install software is by scripting and to install software silently across the network. The launch file is a *.msi file. stakeholder database


----------



## Davecann2 (Feb 9, 2012)

@Cobra35y,

I took into consideration that if I create a VB script and hard code admin credentials I run the risk of vulnerability. Instead of installing the GPO under...

User Configuration/Policies/Software Settings/Software Installation

... and adding the MSI package at the user level... I instead applied the MSI install at the computer level at...

Computer Configuration/Policies/Software Settings/Software Installation

... This allowed the install when the machine is rebooted before the user logs on. I still faced the issue of the application not functioning because it is "User profile specific". My next step was to create a .reg file that would modify the users registry to allow the application to function. I simply exported the working registry key of a user and added into the GPO to be applied when the user logs in.

I know I may have over complicated my task but it worked flawlessly =) My team and i are actively looking into a Software Deployment Software solution.

Thanks again for all your feedback.
All the Best!


----------

