UltraEdit v16.10
Hello all,
I'm trying to script a silent install for UltraEdit 16.10. In my script, the first time i run it, the msiexec for some reason does not create the directory. But if i run it a second time, it then creates the directory and installs OK. I cannot for the life of me understand what exactly is going on. Here is my script:
I'm pretty sure there's no syntax errors in the script. The debugger shows the install aborts the first time when it tries to copy a file to C:\Program Files\IDM Computer Solutions which doesn't exist for some reason at that point in the installation. Then running it a second time, it installs and registers just fine, and the C:\Program Files\IDM directory is there. Does anyone know what i'm doing wrong or has anyone else encountered this issue before.
Thanks very much, any input is appreciated..
I'm trying to script a silent install for UltraEdit 16.10. In my script, the first time i run it, the msiexec for some reason does not create the directory. But if i run it a second time, it then creates the directory and installs OK. I cannot for the life of me understand what exactly is going on. Here is my script:
Option Explicit
'On Error Resume Next
Dim shell, fso, wn, allUsers, userProfile, winDir, computerName, systemDrive, programs
Dim tempDir,programsx86,winTempDir,progDir,oEnv
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wn = Wscript.CreateObject("Wscript.Network")
Set oEnv = Shell.Environment("PROCESS")
Const FOR_READING = 1, FOR_WRITING = 2, FOR_APPENDING = 8
Const WBEM_FLAG_RETURN_IMMEDIATELY = &h10
Const WBEM_FLAG_FORWARD_ONLY = &h20
'Returns C:\Documents and Settings\All Users
allUsers = ucase(Shell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%"))
'Returns C:\Documents and Settings\%Username%
userProfile = ucase(Shell.ExpandEnvironmentStrings("%USERPROFILE%"))
'Returns C:\Windows
winDir = ucase(Shell.ExpandEnvironmentStrings("%WINDIR%"))
'returns computername
computerName = ucase(Shell.ExpandEnvironmentStrings("%COMPUTERNAME%"))
'returns C:\
systemDrive = ucase(Shell.ExpandEnvironmentStrings("%SYSTEMDRIVE%"))
'returns c:\program files
programs = ucase(Shell.ExpandEnvironmentStrings("%PROGRAMFILES%"))
'returns c:\program files (x86) - for 64bit systems
programsx86 = UCase (Shell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%"))
'returns c:\documents and settings\user\local settings\temp
tempDir = ucase(Shell.ExpandEnvironmentStrings("%TEMP%"))
'returns c:\windows\temp
winTempDir = winDir & "\temp"
'check if 64bit program files is present, set variable to correct path
If fso.FolderExists (programsx86) Then
progDir = programsx86
Else
progDir = programs
End If
oEnv("SEE_MASK_NOZONECHECKS") = 1
writeNtEvent 4,"Starting UltraEdit install now"
'Uninstalling old version
writeNtEvent 4,"uninstalling old version of UltraEdit"
Shell.Run "msiexec /X {384BDD6A-58AB-4556-B393-7084DD35EBF8} /qn",True
'Installing new version
Shell.Run "msiexec /i " & winTempDir & "\ultraedit\ue_english.msi /qn /norestart ALLUSERS=1",0,True
'Registering
Fso.CopyFile winTempDir & "\ultraedit\uedit32.reg",progDir & "\IDM Computer Solutions\UltraEdit\",True
'Cleanup
Fso.CopyFile allUsers & "\Start Menu\Programs\UltraEdit\UltraEdit Text Editor.lnk", allUsers & "\Start Menu\Programs\Applications\",True
Fso.CopyFolder allUsers & "\Start Menu\Programs\UltraEdit", allUsers & "\Start Menu\Programs\Utilities\",True
Fso.DeleteFolder allUsers & "\Start Menu\Programs\UltraEdit",True
Fso.DeleteFile allUsers & "\Desktop\UltraEdit.lnk",True
writeNtEvent 4, "Script Complete
oEnv.Remove("SEE_MASK_NOZONECHECKS")
'*****************************************************************************
'c
Sub writeNtEvent(eventID,eventMsg)
'this sub will write an event to the windows nt event viewer.
Const SUCCESS = 0
Const ERROR = 1
Const WARNING = 2
Const INFORMATION = 4
Const AUDIT_SUCCESS = 8
Const AUDIT_FAILURE = 16
Shell.LogEvent eventID,eventMsg & vbNewLine & "Source Script: " & WScript.ScriptName
End Sub
I'm pretty sure there's no syntax errors in the script. The debugger shows the install aborts the first time when it tries to copy a file to C:\Program Files\IDM Computer Solutions which doesn't exist for some reason at that point in the installation. Then running it a second time, it installs and registers just fine, and the C:\Program Files\IDM directory is there. Does anyone know what i'm doing wrong or has anyone else encountered this issue before.
Thanks very much, any input is appreciated..
0 Comments
[ + ] Show comments
Answers (9)
Please log in to answer
Posted by:
anonymous_9363
14 years ago
Ummmmm....why not simply merge your .REG into the MSI or, if this is a vendor-supplied MSI, into a transform? You can add and delete your shortcuts in there, too.
Lastly, judicious use of the Upgrade table could enable uninstallation of previous versions.
All of the above renders the script obsolete.
Lastly, judicious use of the Upgrade table could enable uninstallation of previous versions.
All of the above renders the script obsolete.
Posted by:
dontknowmuch
14 years ago
ORIGINAL: VBScab
Ummmmm....why not simply merge your .REG into the MSI or, if this is a vendor-supplied MSI, into a transform? You can add and delete your shortcuts in there, too.
Lastly, judicious use of the Upgrade table could enable uninstallation of previous versions.
All of the above renders the script obsolete.
Thanks for your reply.
It is a vendor-supplied MSI so merging with the .REG file would be...impossible? Not too sure. Is a transform something I can add to the script?
I'm not sure what the upgrade table is or how to use it judiciously.
The script is obsolete? OK now i'm really confused!
Posted by:
timmsie
14 years ago
A transform is a file you can use to make changes to an msi.
http://msdn.microsoft.com/en-us/library/aa367447%28VS.85%29.aspx
one way to create one is make a copy of the vendor msi and make changes. then use msitran to create an mst
http://msdn.microsoft.com/en-us/library/aa370495%28VS.85%29.aspx
there are tools that will capture response transforms for you etc etc
but this will be a massive learning curve, and doesn't really help you
http://msdn.microsoft.com/en-us/library/aa367447%28VS.85%29.aspx
one way to create one is make a copy of the vendor msi and make changes. then use msitran to create an mst
http://msdn.microsoft.com/en-us/library/aa370495%28VS.85%29.aspx
there are tools that will capture response transforms for you etc etc
but this will be a massive learning curve, and doesn't really help you
Posted by:
anonymous_9363
14 years ago
Posted by:
dontknowmuch
14 years ago
Thanks, that kind of worked when i uninstalled the old version manually, but now its throwing a wscript error on my new line of code at runtime :
"File already exists"
I added two lines right after the uninstall line:
and didn't change anything else.
"File already exists"
I added two lines right after the uninstall line:
Fso.CreateFolder progDir & "\IDM Computer Solutions"
Fso.CreateFolder progDir & "\IDM Computer Solutions\UltraEdit"
and didn't change anything else.
Posted by:
anonymous_9363
14 years ago
Posted by:
dontknowmuch
14 years ago
OK, so now i added two lines above THOSE lines to delete the folders after uninstall :
and i get a wscript runtime error that says "Permission Denied".(referring to the line the new code is on)..
But if i were to go in and try and delete them manually i have no problems.
Fso.DeleteFolder progDir & "\IDM Computer Solutions\UltraEdit"
Fso.DeleteFolder progDir & "\IDM Computer Solutions"
and i get a wscript runtime error that says "Permission Denied".(referring to the line the new code is on)..
But if i were to go in and try and delete them manually i have no problems.
Posted by:
anonymous_9363
14 years ago
As you may well come to learn if you spend any time here, one of the drums that I bang very loudly is "proper error-trapping in script". Always assume that NOTHING will work so, in this case for example, right after you create a folder, you should test that it actually got created. Indeed, you should also have tested right at the start that the FileSystemObject object got created (IsObject). Very quickly, you'll learn to have a CheckError function in all your scripts, to save endlessly repeating reams and reams of code like 'If Err.Number <> 0 Then...' In fact, seek out some of the Microsoft script samples, using 'BugAssert' as your search term. They are a neat illustration of what I mean, although not all MS's scripts display similar discipline. That brings us neatly to another drum: Microsoft's consistent inconsistency. Don't get me started...
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.