Jump to content

Runonce issues or my coding errors


Recommended Posts

I have been using the runonce keys in windows 7 for quite some time, but I finally hit something I can't figure out..

I am attempting to update an instance of Oracle DB and I am having an issue with how runonce is behaving.. I am using autoit to make the regkeys and they all seem to work normal, until the last step..

The code for each step is broken down into three steps.. 1. turn off / set  services to demand (manual), 2. run the opatch command, 3. turn the services to automatic / on and run some sql files.

Here is the code for the run once..

If @OSVersion = "WIN_7" then $path = "D:\"
If @OSVersion = "WIN_2008R2" then $path = "C:\"

RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx", "Flags", "REG_DWORD", "20")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx", "TITLE", "REG_SZ", "Running Oracle Update")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001", "", "REG_SZ", "Oracle Update Part 2")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001", "101", "REG_SZ", $path & @OSArch & "\OracleCPUSAMSEPart2.exe")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001", "102", "REG_SZ", "shutdown -t 0 -r -f")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0002", "", "REG_SZ", "Oracle Update Part 3")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0002", "101", "REG_SZ", $path & @OSArch & "\OracleCPUSAMSEPart3.exe")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0002", "102", "REG_SZ", "shutdown -t 0 -r -f")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0003", "", "REG_SZ", "Cleanup")
RegWrite("HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0003", "101", "REG_SZ", "D:\cleanup.exe")

Since this is broken down into three steps here is the code for the steps, which is ran before the runonce keys are written

Step1.exe (works / runs before the runonce keys are written)

RunWait("sc config SAMSEFTP start= Demand","",@SW_HIDE)
RunWait("sc config MSDTC start= Demand","",@SW_HIDE)
RunWait("sc config OracleServiceSAMSE start= Demand","",@SW_HIDE)
RunWait("sc config OracleOraDb11g_home1TNSListener start= Demand","",@SW_HIDE)
RunWait('sc config "EFT Server" start= Demand',"",@SW_HIDE)
RunWait("sc config MatSchedulerService start= Demand","",@SW_HIDE)
RunWait("sc stop SAMSEFTP","",@SW_HIDE)
RunWait("sc stop MSDTC","",@SW_HIDE)
RunWait("sc stop OracleServiceSAMSE","",@SW_HIDE)
RunWait("sc stop OracleOraDb11g_home1TNSListener","",@SW_HIDE)
RunWait('sc stop "EFT Server"',"",@SW_HIDE)
RunWait("sc stop MatSchedulerService","",@SW_HIDE)

Step2.exe (works)

If @OSVersion = "WIN_7" then $path = "D:\"
If @OSVersion = "WIN_2008R2" then $path = "C:\"

FileInstall(".\runOPatch.CMD", $path & @OSArch & "\files\runOPatch.CMD")
FileInstall(".\regDll.CMD", $path & @OSArch & "\files\regDll.CMD")

RunWait($path & @OSArch & "\files\runOPatch.CMD",$path & @OSArch)
RunWait($path & @OSArch & "\files\regDll.CMD",$path & "app\sams.admin\product\11.2.0\dbhome_1\ODP.NET\bin\2.x")
RunWait($path & @OSArch & "\files\regDll.CMD",$path & "app\sams.admin\product\11.2.0\dbhome_1\ODP.NET\bin\4")

RunWait('sc config SAMSEFTP start= Auto',"",@SW_HIDE)
RunWait('sc config MSDTC start= Demand',"",@SW_HIDE)
RunWait('sc config OracleServiceSAMSE start= Auto',"",@SW_HIDE)
RunWait('sc config OracleOraDb11g_home1TNSListener start= Auto',"",@SW_HIDE)
RunWait('sc config "EFT Server" start= Auto',"",@SW_HIDE)
RunWait('sc config MatSchedulerService start= Auto',"",@SW_HIDE)

Step3.exe (doesn't seem to run)

#include ".\Services.au3"

Global $ServiceStatus,$service

RunWait('net start "EFT Server"','',@sw_hide)

If @OSVersion = "WIN_7" then $path = "D:\"
If @OSVersion = "WIN_2008R2" then $path = "C:\"

FileInstall(".\RunCpu.sql", $path & @OSArch & "\files\RunCpu.sql")
FileInstall(".\runUtlrp.sql", $path & @OSArch & "\files\runUtlrp.sql")
FileInstall(".\PatchCleanup.sql", $path & @OSArch & "\files\PatchCleanup.sql")

RunWait("sqlplus /nolog @" & $path & @OSArch & "\files\RunCpu.sql",$path & "app\sams.admin\product\11.2.0\dbhome_1\Bundle\Patch28")
RunWait("sqlplus /nolog @" & $path & @OSArch & "\files\runUtlrp.sql",$path & "app\sams.admin\product\11.2.0\dbhome_1\RDBMS\ADMIN")
RunWait("sqlplus /nolog @" & $path & @OSArch & "\files\PatchCleanup.sql",$path & @OSArch & "\files")
if FileExists($path & "app\sams.admin\product\11.2.0\dbhome_1\ccr\") Then DirRemove($path & "app\sams.admin\product\11.2.0\dbhome_1\ccr\",1)
DirRemove($path & @OSArch &"\",1)

func _ServiceStatus($service)
    RunWait("net start " & $service,'',@sw_hide)
    $ServiceStatus = _Service_QueryStatus($service)
until $ServiceStatus[1] = "4"

I think the problem lies with how runonce keys are called.. Meaning the runonce runs step2, then runs the reboot command, then imediately launches step3.exe (i see the bolded text move onto the next item), then the system reboots.. upon reboot step3.exe is still there, but it sits there for a few seconds then moves onto cleanup.. So either the runonce is calling it or there is an issue with my step3.exe

I can run each step manually and they run fine.. it is either the runonce or something else is nto running properaly.. I know there is something I am missing, but i cant figure it out.. and it is probably pretty easy.. Also the reboot in the runonce after step3 never happens.. This is another reason I think it is a runonce problem and not a autoit problem, but MSFN keeps timing out and I wanted to post this before I went home and will post there once I am not proxied..

Thanks for the help..

Edited by myk3
Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...