Jump to content


  • 0
P@docIT

Installing software via powershell

Question

Afternoon all,

 

I am trying to setup a simple script that will determine if Drive E: exists and if so is it a CD Rom drive. Then based on that info run install command line. The if else logic seems to work but I'm having a hard time getting the install cmd to run. Any help would be greatly appreciated, I'm also open to other ways of doing this.

 

Exit code btw is 1622.

 

Cheers,

Mike

$instdir = Get-WmiObject -Class Win32_LogicalDisk |
    Where-Object {$_.DeviceID -eq "E:"}
If (!($instdir)){
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"C:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }

ElseIf ($instdir.DriveType -eq "5"){
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"C:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }

Else {
    $process = start-process -filepath "setup.exe" -argumentlist '/s /v"/l*voicewarmup \"%temp%\besclientinstall.log\" INSTALLDIR=\"E:\Program Files (x86)\BigFix Enterprise\BES Client\" /qn"' -Wait -PassThru
    }
    $process.ExitCode

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thanks Peter. Removing the trailing backslash from the from the log path got rid of the 1622 error, but now I'm getting a 1203 error. Which appears to be:

 

ERROR_NO_NET_OR_BAD_PATH

The network path was either typed incorrectly, does not exist, or the network provider is not currently available. Please try retyping the path or contact your network administrator.

1203 (0x4B3)

Share this post


Link to post
Share on other sites

  • 0

Ended up using VBS, works well.

Option Explicit
Dim objWMIService, objItem, colItems, strComputer, fso, WshShell, oExec
On Error Resume Next
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select DriveType from Win32_LogicalDisk Where DeviceID = 'E:'")

Set fso = WScript.CreateObject("Scripting.FileSystemObject")

If Not fso.DriveExists("E:") Then
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""C:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
 Else
	For Each objItem in colItems
	'Wscript.Echo "Description: " & objItem.Description
        'Wscript.Echo "DeviceID: " & objItem.DeviceID
        'Wscript.Echo "DriveType: " & objItem.DriveType
If objItem.DriveType = 3 Then
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""E:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
Else
	Set WshShell = WScript.CreateObject("WScript.Shell")
		Set oExec = WshShell.Exec("setup.exe /s /v""/l*voicewarmup \""%temp%\besclientinstall.log\"" INSTALLDIR=\""C:\Program Files (x86)\BigFix Enterprise\BES Client\"" /qn""")
		x = oExec.StdOut.ReadLine
		'Wscript.Echo x
End If

	Next
  
End If

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.