/build/static/layout/Breadcrumb_cap_w.png

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:



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)

Posted by: anonymous_9363 13 years ago
Red Belt
0
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.
Posted by: dontknowmuch 13 years ago
Senior Yellow Belt
0
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 13 years ago
Fourth Degree Brown Belt
0
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
Posted by: anonymous_9363 13 years ago
Red Belt
0
If you wish to persist with the script, it would be an idea to add the creation of the target folder to it! I suspect that the reason that the script works the second time is because the MSI creates that folder.
Posted by: dontknowmuch 13 years ago
Senior Yellow Belt
0
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:


Fso.CreateFolder progDir & "\IDM Computer Solutions"
Fso.CreateFolder progDir & "\IDM Computer Solutions\UltraEdit"


and didn't change anything else.
Posted by: anonymous_9363 13 years ago
Red Belt
0
Look up (devguru.com has an excellent VBScript reference) the FileSystemObject functions FolderExists and FileExists.
Posted by: dontknowmuch 13 years ago
Senior Yellow Belt
0
OK, so now i added two lines above THOSE lines to delete the folders after uninstall :


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: dontknowmuch 13 years ago
Senior Yellow Belt
0
So youre saying test for the condition first...OK will try.
Posted by: anonymous_9363 13 years ago
Red Belt
0
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.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ