Sign in to follow this  
Followers 0
BPBNA

Win2k Issues

13 posts in this topic

#1 ·  Posted (edited)

Hi,

I'm writing a program for my company that installs a couple of critical Windows updates for our users. I can get the Windows XP side of it to work, but not the Windows 2000 part. I'm pretty sure everything looks fine but when I run it, I get the initial MsgBox then it skips to the one that should only run after the updates are completed. Are there certain functions that I used that don't work in Win2k?

Heres the code:

CODE
#NoTrayIcon

If @OSVersion = "Win_XP" Then

$start = MsgBox(36, "Windows XP Security Updates", "You are about to install the Windows XP security updates." & @CR _

& "While this program is running, you may continue working normally." & @CR _

& "Would you like to begin the updates now?")

If $start = 7 Then Exit

RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KB914388", "DisplayName")

If @error = 1 Then

DirRemove("C:\XPUpdate", 1)

DirCreate("C:\XPUpdate")

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\WinXP\WindowsXP-KB914388-x86-ENU.exe", "C:\XPUpdate\WindowsXP-KB914388-x86-ENU.exe", 1)

RunWait(@ComSpec & " /c C:\XPUpdate\WindowsXP-KB914388-x86-ENU.exe /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)

$kb914388 = 1

Else

$kb914388 = 0

EndIf

RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KB921883", "DisplayName")

If @error = 1 Then

DirRemove("C:\XPUpdate", 1)

DirCreate("C:\XPUpdate")

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\WinXP\WindowsXP-KB921883-x86-ENU.exe", "C:\XPUpdate\WindowsXP-KB921883-x86-ENU.exe", 1)

RunWait(@ComSpec & " /c C:\XPUpdate\WindowsXP-KB921883-x86-ENU.exe /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)

$kb921883 = 1

Else

$kb921883 = 0

EndIf

ElseIf @OSVersion = "Win_2000" Then

$start = MsgBox(65, "Windows 2000 Security Updates", "You are about to install the Windows 2000 security updates." & @CR _

& "While this program is running, you may continue working normally." & @CR _

& "Would you like to begin the updates now?")

If $start = 2 Then Exit

RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KB914388", "DisplayName")

If @error = 1 Then

DirRemove("C:\2kUpdate", 1)

DirCreate("C:\2kUpdate")

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\Win2k\Windows2000-KB914388-x86-ENU.EXE", "C:\2kUpdate\Windows2000-KB914388-x86-ENU.EXE", 1)

RunWait(@ComSpec & " /c C:\2kUpdate\Windows2000-KB914388-x86-ENU.EXE /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)

$kb914388 = 1

Else

$kb914388 = 0

EndIf

RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\KB921883", "DisplayName")

If @error = 1 Then

DirRemove("C:\2kUpdate", 1)

DirCreate("C:\2kUpdate")

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\Win2k\Windows2000-KB921883-x86-ENU.EXE", "C:\2kUpdate\Windows2000-KB921883-x86-ENU.EXE", 1)

RunWait(@ComSpec & " /c C:\XPUpdate\Windows2000-KB921883-x86-ENU.EXE /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)

$kb921883 = 1

Else

$kb921883 = 0

EndIf

Else

MsgBox(16, "Error", "You must be running Windows XP or Windows 2000 to run this file.")

EndIf

If $kb914388 And $kb921883 Then

$restart = MsgBox(36, "Update", "The following updates were successfully installed:" & @CR & @CR _

& "Security Update - KB914388" & @CR _

& "Security Update - KB921883" & @CR _

& @CR & "For the changes to take effect, the computer must be restarted." & @CR & "Would you like to restart now?")

ElseIf $kb914388 And Not $kb921883 Then

$restart = MsgBox(36, "Update", "The following updates were successfully installed:" & @CR & @CR _

& "Security Update - KB914388" & @CR _

& @CR & "For the changes to take effect, the computer must be restarted." & @CR & "Would you like to restart now?")

ElseIf Not $kb914388 And $kb921883 Then

$restart = MsgBox(36, "Update", "The following updates were successfully installed:" & @CR & @CR _

& "Security Update - KB921883" & @CR _

& @CR & "For the changes to take effect, the computer must be restarted." & @CR & "Would you like to restart now?")

ElseIf Not $kb914388 And Not $kb921883 Then

MsgBox(64, "Information", "The updates are already installed. Your computer is up to date.")

Exit

EndIf

If $restart = 6 then

Shutdown(6)

Else

Exit

EndIf

Edited by BPBNA

Share this post


Link to post
Share on other sites



Perhaps this:

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\Win2k\Windows2000-KB921883-x86-ENU.EXE", "C:\2kUpdate\Windows2000-KB921883-x86-ENU.EXE", 1)

RunWait(@ComSpec & " /c C:\XPUpdate\Windows2000-KB921883-x86-ENU.EXE /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Ok, so I fixed that typo but it should still run the second update should it not? After fixing that and testing it again, it still would not run either update.

Share this post


Link to post
Share on other sites

Well, for one thing @comspec is not needed, as you are running actual EXEs, and not DOS commands (like DIR). So take out @comspec and /c

Second, it's hard to tell what your EXEs are actually doing if you can't see them. Try taking out the @SW_HIDEs, perhaps you'll get a glimpse of an error message or two.

Third, The second parameter of RunWait is the directory in which to run the EXE. I suggest using it. Take the "C:\XPUpdate\" out of the first parameter and use it as the second parameter.

Fourth, if you still have trouble, try placing MsgBoxes inbetween all of the parts of your script, and check to see that the script really has done what you want. Like $var = regread(something), msgbox("$var should equal x, does it?",$var), or DirCreate(blah), msgbox("Directory Blah should exist, please go make sure it does...") etc. This is a crude but effective way of doing unit testing.

Good luck.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Well the @SW_HIDE just hides the command window, not my program, that part works fine. It turns out the problem is that the files aren't being copied, but the directory is there. Does FileInstall not work on Win2k? Do I need to use RunAsSet?

Share this post


Link to post
Share on other sites

FileInstall will work, but you might not want to use it in this case. Why not do this instead:

FileCopy ( "\\server\updates\Windows2000-KB921883-x86-ENU.EXE", "C:\2kUpdate\" ,1+8 )

That will make your script a LOT smaller too.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

I can't use the FileCopy that way since not all our users that are receiving this will be on the network. Our sales reps just use laptops. I could have the file in a seperate directory but I would rather use FileInstall since some people decide its better to go into the directory and run each update seperatly. Obviously that would cause issues if they installed an XP patch on a W2k machine or vice versa(if they would even run). The update is also supposed to be run in a way that they cannot uninstall it since these are mandatory system updates for us. It should also be silent so they don't have to see or do anything. Only other thing I could think of is making the directory hidden. I would still rather use FileInstall though if possible. Any ideas?

Share this post


Link to post
Share on other sites

Um, how are you getting the file to them? Email? I hope they're not on dialup.

Okay, well, try the file install differently. I always put the file I want to include on my machine where I want it, and fileinstall it to itself. Like this:

FileInstall("C:\2kUpdate\Windows2000-KB914388-x86-ENU.EXE", "C:\2kUpdate\Windows2000-KB914388-x86-ENU.EXE", 1)

Make sure you have a backup of each of the EXEs before you try this.

If you can host the files on the network, it would be better for everyone. Perhaps you can send them a link in their email like this:

\\server\update\update.exe

but the update.exe can filecopy from

\\server\updateExes$\blah.exe

Putting the $ at the end of the share name hides it. They'd never know where the file was coming from, but they would have to be connected to the network for the whole thing to work.

I might reccomend that you add some logging to this, like

filewriteline("\\server\update\logs\logs.txt",@username &" on "&@ComputerName&" installed "&$updatename)

so you know how well it's working


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

The file will be deployed in a couple different ways. We are planning on incorporating it into a logon script for our in-office users, and we are sending an email to the mobile users. They are small updates. With all 4 updates compiled into the exe, it is just under 3mb. Installling the updates from the server is out of the question, the files need to come with the exe in some way.

Keep in mind that my program works fine in Windows XP. I'm just trying to figure out why it wont copy the files over in Windows 2000. I'm testing out a version with RunAsSet right now. I will let you know how it goes.

Share this post


Link to post
Share on other sites

Perhaps this:

FileInstall("C:\Documents and Settings\chrisw\Desktop\critical updates\Win2k\Windows2000-KB921883-x86-ENU.EXE", "C:\2kUpdate\Windows2000-KB921883-x86-ENU.EXE", 1)

RunWait(@ComSpec & " /c C:\XPUpdate\Windows2000-KB921883-x86-ENU.EXE /quiet /norestart /overwriteoem /nobackup", "", @SW_HIDE)

Just a quick hunch since I have not read the thread but I belive RunWait will terminate you script if the command fails. Check:

opt("RunErrorsFatal", 0)

Share this post


Link to post
Share on other sites

Well using the RunAsSet worked! I also changed C: to @HomeDrive just incase. Thanks for the help lod3n!

Share this post


Link to post
Share on other sites

Ohh, RunAsSet can be scary. If they decompile your script they'll have the username and password. At least use a local machine account, and not a domain admin account.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Heh, I dont think any of our users know how to decompile one of these... especially since the majority of them don't even know what the Control Panel is. Also, that is not the network admin account/pass that I use. It is just a local one that we set. I also decided to put Smoke_N's EnCodeIt to use to make it even more difficult if someone does manage to decompile it or anything.

Edited by BPBNA

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0