Page 1 of 1 1
Topic Options
#189013 - 2008-08-04 03:24 PM Installing an msi file with sanur.exe
xempa Offline
Fresh Scripter

Registered: 2006-08-12
Posts: 37
Hi

I am trying to convert this batch file into kix any help here would be most appreciated. Despite best efforts I can't seem to get the syntax right

this werks perfectly as a batch file but any help would be appreciated

echo off
runas /u:home\Administrator "msiexec /i \\PC01948\C$\Deployment\WBC.msi" | \\Pc01948\netlogon\scripts\sanur /i \\pc01948\netlogon\scripts\test.dat



many thanks

Top
#189019 - 2008-08-04 04:47 PM Re: Installing an msi file with sanur.exe [Re: xempa]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
This should work for you.. Really, you could use SHELL or RUN to achieve the same result - just watch the quoting.

 Code:
$FileHome = '\\PC01948\C$\Deployment\'
$ScriptHome = '\\pc01948\netlogon\scripts\'
SHELL '%comspec% /c runas /u:home\Administrator "msiexec /i '+$FileHome+'WBC.msi" | '+$ScriptHome+'sanur /i '+$ScriptHome+'test.dat'


Thanks,

Kent


Edited by Kdyer (2008-08-04 04:51 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#189021 - 2008-08-05 01:48 PM Re: Installing an msi file with sanur.exe [Re: xempa]
xempa Offline
Fresh Scripter

Registered: 2006-08-12
Posts: 37
Hi Kyder

Many thanks for that I've made the following adjustments as per your suggestions and it works !. However I have a further situation where writeValue to the registry doesn't work for Domain users. I'm thinklng permissions but where ? Your's or anyone's help on this would be appreciated . many thanks

see code below


$FileHome = '\\PC01948\C$\Deployment\'
$ScriptHome = '\\PC01948\netlogon\scripts\'
$ScriptMSI = '\\PC01948\C$\Deployment\'


If NOT ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Waikaremoana') = 1
SHELL '%comspec% /c runas /u:home\Administrator "msiexec /i '+$ScriptMSI+'WBC.msi" | '+$ScriptHome+'sanur /i '+$ScriptHome+'test.dat'
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Waikaremoana','1','REG_DWORD')
EndIf


$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM Win32_DesktopMonitor")
For Each $wmiObj In $wmiColl
Select
Case $wmiObj.DeviceID = "DesktopMonitor1"
$screenres1 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight)
Case $wmiObj.DeviceID = "DesktopMonitor2"
$screenres2 = CSTR($wmiObj.ScreenWidth) + "x" + CSTR($wmiObj.ScreenHeight)
EndSelect
Next


select
case $screenres1 = "1024x768"
If NOT ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Sheild 1024x768') = 1
SHELL '%comspec% /c runas /u:home\Administrator "msiexec /i '+$ScriptMSI+'Shield1280.msi" | '+$ScriptHome+'sanur /i '+$ScriptHome+'test.dat'
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Sheild 1024x768','1','REG_DWORD')
EndIf

case $screenres1 = "800x600"
If NOT ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Sheild 800x600') = 1
SHELL '%comspec% /c runas /u:home\Administrator "msiexec /i '+$ScriptMSI+'Shield800.msi" | '+$ScriptHome+'sanur /i '+$ScriptHome+'test.dat'
WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Sheild 800x600','1','REG_DWORD')
EndIf

case 1
; Must be using some other resolution
endselect


;REG_SZ

;$logfile = "\\sapdc\NETLOGON\MSI\MSI Batch Files\Citlogon.log"
;$RC = Open(1, $logfile, 5)
;$RC = WriteLine(1,"Logon Time: "+@USERID+", "+@WKSTA+", "+@Day+", "+@DATE+","+@TIME+@CRLF+)

Top
#189022 - 2008-08-05 02:26 PM Re: Installing an msi file with sanur.exe [Re: xempa]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I think you may want to look at the parameters of MSIEXEC..
http://msdn.microsoft.com/en-us/library/aa367988.aspx

More specifically with the TRANSFORMS component ( the /t for the MST files): http://documentation.installshield.com/robo/projects/installshieldxhelplib/IHelpCmdLineMSI.htm

Here are some great articles here:
http://www.appdeploy.com/

HTH,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#189025 - 2008-08-05 11:34 PM Re: Installing an msi file with sanur.exe [Re: xempa]
xempa Offline
Fresh Scripter

Registered: 2006-08-12
Posts: 37
Hi Kyder

Many thanks for your help here. However I'm not sure I understand correctly your response

Under both scenarios as administrator and domain user all MSI files install perfectly.

My prob comes about when using kix writeValue to write to the registry. This writes fine if you have logged in as an admin but not domain user.


oddly enought I originlly called a batch file inside kix that ran sanur successfully (with admin privildeges to install the msi) then immediately proceeding a writevalue in kix and this worked well.

I saw some earlier documentation where it stated a domain user could only write to HKCU not HKLM ?

However I think maybe the way I'm calling sanur it's not holding it's admin priveledge long enough to write to the registry

Hope this makes sense

cheers
Cheers

Top
#189029 - 2008-08-06 08:56 AM Re: Installing an msi file with sanur.exe [Re: xempa]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
What does the writevalue function return? The way you use it you should see some numbers on the screen.

If not you can put the code below beneath each writevalue line to see what is happening.

 Code:
?@error
?@serror
sleep 2


All numbers are error codes. Here http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx you will find a list of all error codes.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#189032 - 2008-08-06 10:09 AM Re: Installing an msi file with sanur.exe [Re: xempa]
xempa Offline
Fresh Scripter

Registered: 2006-08-12
Posts: 37
Thanks Mark and Kyder

I think I've just nailed it. It's because as domain user you don't have permissions to write to the HKLM. This script now works because I am writing to HKCU instead.

Also possibly the way I referenced HKCU as per HKEY_CURRENT_USER that it is now working ?

This works:

WriteValue('HKEY_CURRENT_USER\Software\Microsoft\Updates','Waikaremoana','1','REG_DWORD')


This doesn't

WriteValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates','Waikaremoana','1','REG_DWORD')


Many thanks to you both for helping me though this

Cheers

Top
#189034 - 2008-08-06 11:06 AM Re: Installing an msi file with sanur.exe [Re: xempa]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Quote:
I think I've just nailed it. It's because as domain user you don't have permissions to write to the HKLM.


You're nearly correct. Each key in the registry has a permission. This is very like the permissions on folders in the file systems, and you can view them using regedit.

This means that you *can* write to HKLM, as long as you are granted permission to.

The key that you were trying to write to is part of the policy feature of Windows, which is used by administrators to enforce configuration. Of course you don't want your users to be able to write to this area, otherwise they could undo any restriction in place.

It is for this reason you cannot write to "\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Updates" - it doesn't matter if you prefix it with HKCU or HKEY_CURRENT_USER, both will fail.

I recommend that you create your own key e.g. "HKCU\software\Xempa" and write your value there.

Top
#189048 - 2008-08-06 11:05 PM Re: Installing an msi file with sanur.exe [Re: xempa]
xempa Offline
Fresh Scripter

Registered: 2006-08-12
Posts: 37
Awesome Richard

Thanks very much for this info , this is useful to know

Many thanks

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.038 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org