Solved

Startup Script to Install Software

Posted on 2009-07-03
9
792 Views
Last Modified: 2012-05-07
I have several software applications that run mostly on the clients, but passing information to a database on the server.  They connect to the server via a mapped network drive.  I would like to do a remote silent install to all the clients via a startup.  I've created the appropriate setup.iss files but I'm having a problem with the script.  I get an error at line 28 that the file isn't available.  It would appear that the mapped drive doesn't exist yet.

If I map a drive at the client and remove the commands to create the mapped drive from the script, it runs successfully by linking to it from the client via "My Network Places."

Any suggestions greatly appreciated.
'

' A script to install software in silent mode using a setup.iss file

'

'--------------------------------------------------------------------

Option Explicit

'

Dim objNetwork, strDriveLetter, strRemotePath, boolPersistent

Dim objFSO, execFile, setupFile, WSHShell

'

' Purpose of script to create a network object. (objNetwork)

' Then to apply the MapNetworkDrive method.  Result Z: drive

'

strDriveLetter = "Z:" 

strRemotePath = "\\SERVER\SHARE"

boolPersistent = True 

 

Set objNetwork = CreateObject("WScript.Network") 

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, boolPersistent

'

' Now we install the software

'

Set objFSO = CreateObject("Scripting.FileSystemObject")

'

execFile = "Z:\APP1\Setup.exe"

setupFile = "Z:\APP1\setup.iss"

' 

Set WshShell = WScript.CreateObject("WScript.Shell") 	

WSHShell.Run chr(34) & execFile & Chr(34) & " -s -f1" & Chr(34) & setupFile & Chr(34)

Open in new window

0
Comment
Question by:767WuLiMaster
  • 5
  • 4
9 Comments
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi there,

When you run scripts at StartUp, then by default, the Local System account that the script runs under does have access to any network resource, aside from the NetLogon share of your domain controllers.

Therefore, if you place your Exec file and Setup file somewhere within your NetLogon share, you should be able to get away with running the following code, where you replace each instance of domain.com in the file paths with your domain name.

Regards,

Rob.
'

' A script to install software in silent mode using a setup.iss file

'

'--------------------------------------------------------------------

Option Explicit

'

Dim objNetwork, strDriveLetter, strRemotePath, boolPersistent

Dim objFSO, execFile, setupFile, WSHShell

'

' Now we install the software

'

Set objFSO = CreateObject("Scripting.FileSystemObject")

'

execFile = "\\domain.com\sysvol\domain.com\scripts\APP1\Setup.exe"

setupFile = "\\domain.com\sysvol\domain.com\scripts\APP1\setup.iss"

' 

Set WshShell = CreateObject("WScript.Shell") 	

WSHShell.Run chr(34) & execFile & Chr(34) & " -s -f1" & Chr(34) & setupFile & Chr(34)

Open in new window

0
 

Author Comment

by:767WuLiMaster
Comment Utility
Rob,

I'm not sure that I understand your solution.  Are you suggesting that the application, including the setup.exe file be moved to the /scripts/ folder?  In my case, that wouldn't be acceptable.  The application runs on a TrueCrypt "drive" which is created from a TrueCrypt container on an eSata drive.  It can't be moved to another location.  I could move the setup.iss file, but not the program itself.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hmmm, that might make it difficult to have the Startup Script access the other network location.

The other thing you could try then, is allowing the local SYSTEM account access to the App1 folder on the original file share.  Go to the NTFS security permissions of the folder, and add the local SYSTEM account.  Then, hopefully your script will have access to it.  You shouldn't need to map the drive though, so just change the file paths to the UNC paths once you have done that.

Regards,

Rob.
0
 

Author Comment

by:767WuLiMaster
Comment Utility
Rob,

That didn't work either.  Under Sharing and Security for the TrueCrypt "drive", I tried SYSTEM with full control.  Also tried Domain/Admin.  No luck.

Under the Properties tab, I set all to full control.  Still no luck.

Last month, I installed a trial version of Windows Server 2008 and the script ran fine on it.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Accepted Solution

by:
767WuLiMaster earned 0 total points
Comment Utility
PROBLEM SOLVED

I tried another approach, using a DOS command file instead of VBS.

:: A startup script to install APP1 on all clients.
:: Makes use of a *.iss file to install in silent mode.
::
:: First we need to establish a mapped network drive even if one is already mapped on the client
NET USE Z: \\SERVER\SHARE
::
:: Now we run setup.exe.
::
Z:\APP1\SETUP.EXE -s -f1Z:\SETUP.ISS

This worked!

Not sure what the problem is using VBS, but need to go with what works.
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Ah very good.  OK, given that, I see two possible issues with the VBS as to why it may not have worked.

First off, there is no error checking on the mapping of the drive, which means if it happened to produce an error, it would have ended the script there.  I have added error checking on the mapping in the code below.

Secondly, the is no space after the -f1 parameter of the caf.exe call.  In the DOS version, you have a space.

Oh, and another "possible" issue, is that the command may *need* to be run at the command prompt.  I have accounted for that too.

Sorry I didn't pick up on these things earlier, but feel free to try the VBS version again if you like.  Otherwise you are able to close the question, accepting your last post as the answer.

Regards,

Rob.
'

' A script to install software in silent mode using a setup.iss file

'

'--------------------------------------------------------------------

Option Explicit

'

On Error Resume Next

Dim objNetwork, strDriveLetter, strRemotePath, boolPersistent

Dim objFSO, execFile, setupFile, WSHShell

'

' Purpose of script to create a network object. (objNetwork)

' Then to apply the MapNetworkDrive method.  Result Z: drive

'

strDriveLetter = "Z:" 

strRemotePath = "\\SERVER\SHARE"

boolPersistent = False

 

Set objNetwork = CreateObject("WScript.Network") 

Set objFSO = CreateObject("Scripting.FileSystemObject")

' Disconnect the drive first in case it is incorrectly mapped

If objFSO.DriveExists(strDriveLetter) = True Then objNetwork.RemoveNetworkDrive strDriveLetter, True, False

WScript.Sleep 1000

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, boolPersistent

'

' Now we install the software

'

execFile = "Z:\APP1\Setup.exe"

setupFile = "Z:\APP1\setup.iss"

' 

Set WshShell = CreateObject("WScript.Shell") 	

WSHShell.Run "cmd /c " & chr(34) & execFile & Chr(34) & " -s -f1 " & Chr(34) & setupFile & Chr(34), 0, False

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
If you change this line
WSHShell.Run "cmd /c " & chr(34) & execFile & Chr(34) & " -s -f1 " & Chr(34) & setupFile & Chr(34), 0, False

to this
WSHShell.Run "cmd /k " & chr(34) & execFile & Chr(34) & " -s -f1 " & Chr(34) & setupFile & Chr(34), 1, False

and then run it manually, what does the DOS prompt say? (don't leave it like this to run it automatically....the /k makes the DOS prompt stay open).

Regards,

Rob.
0
 

Author Comment

by:767WuLiMaster
Comment Utility
Rob,

Finally got it to work as a VBS script.  Problem was with concatination of strings.  Attached is the code.
execFile and setupFile are already strings, so shouldn't be wrapped in quotes.


'

' A script to install software in silent mode using a setup.iss file

'

'--------------------------------------------------------------------

Option Explicit

'

On Error Resume Next

Dim objNetwork, strDriveLetter, strRemotePath, boolPersistent

Dim objFSO, execFile, setupFile, WSHShell, strComm

'

' Purpose of script to create a network object. (objNetwork)

' Then to apply the MapNetworkDrive method.  Result Z: drive

'

strDriveLetter = "Z:" 

strRemotePath = "\\AARP\TWSRVR_Q"

boolPersistent = False

 

Set objNetwork = CreateObject("WScript.Network") 

Set objFSO = CreateObject("Scripting.FileSystemObject")

' Disconnect the drive first in case it is incorrectly mapped

If objFSO.DriveExists(strDriveLetter) = True Then objNetwork.RemoveNetworkDrive strDriveLetter, True, False

WScript.Sleep 1000

objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, boolPersistent

'

' Now we install the software

'

execFile = "Z:\APP1\Setup.exe"

setupFile = "Z:\APP1\setup.iss"

strComm = "cmd /k " & execFile & " -s -f1" & setupFile

' 

Set WshShell = CreateObject("WScript.Shell") 	

WSHShell.Run strComm

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
OK cool. I usually use the quotes in case the file paths have spaces, but you can get around that by using the short path to the files, like that below.

execFile = "Z:\APP1\Setup.exe"
setupFile = "Z:\APP1\setup.iss"
strComm = "cmd /k " & objFSO.GetFile(execFile).ShortPath & " -s -f1" & objFSO.GetFile(setupFile).ShortPath

Regards,

Rob.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I work for a company that primarily works with small businesses as their outsourced IT vendor. As such the majority of these customers utilize some version of Small Business Server. Due to the economics of running a small business, many of these cus…
If you are a user of the discontinued Microsoft Office Accounting 2008 (MSOA) and have to move to a new computer running Windows 8, you will be unhappy to discover that it won't install.  In particular, Microsoft SQL Server 2005 Express Edition (SSE…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

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

10 Experts available now in Live!

Get 1:1 Help Now