LordSphynx Posted November 13, 2007 Share Posted November 13, 2007 I wrote a script to do the installation and customisation of something here.In Windows 2000, the script works like a charm.In Windows 2003, it fails with the error in screenshot.The script is included :expandcollapse popup#comments-start #comments-end ; Includes #include <date.au3> #include <File.au3> #include <_NtServices.au3> ; Functions Func _LogEvent($iType, $sMessage, $sTarget = @ComputerName) ; Adds an event entry to a log file ; Type: 0=Success, 1=Error, 2=Warning, 4=Information, 8=Audit_Success, 16=Audit_Failure Local $oWshShell = ObjCreate("WScript.Shell") If Not @error Then $oWshShell.LogEvent($iType, $sMessage, $sTarget) Return True EndIf EndFunc $ScriptName = "Install Dollar U version 5.0 - By Frederic Kaye" $server = InputBox($ScriptName, "Please enter the servername.") $username = InputBox($ScriptName, "Please enter your privileged Username.") $password = InputBox($ScriptName, "Please enter your password.", "", "*") $domain = InputBox($ScriptName, "Please enter the domain.") $logdir = "C:\TEMP\InstallDollarU\" $logfile = "InstallDollarU.log" $loc_1 = "\\pch.chem.corp.local\global\$data\app-win-universe\SETUP_WINSRV" $loc_2 = "\\pch.chem.corp.local\global\$data\app-win-universe\SCHD1O_WINSRV" $loc_3 = "\\pch.chem.corp.local\global\$data\app-win-universe\PERL_WINSRV" $target_1 = "F:\APPS\universe\SCHD1O\exec" $target_2 = "F:\APPS\universe\SCHD1O\mgr" $target_3 = "F:\APPS\universe\tools" $target_4 = "C:\Documents and Settings\All Users\Desktop" ; The Script TrayTip($ScriptName, "Busy ...", 18000, 1) If FileExists($logdir & $logfile) Then FileMove($logdir & $logfile, $logdir & "InstallDollarU.bck", 1) Else DirCreate($logdir) EndIf $OpenLog = FileOpen($logdir & $logfile, 9) FileWriteLine($OpenLog, "Dollar U Automatic Installation by AutoIT." & @CRLF & @CRLF) FileWriteLine($OpenLog, "Installation Date/Time: " & _Now() & @CRLF & @CRLF) ; Copy Files RunAsSet($username, $domain, $password, 2) DriveMapAdd("B:", $loc_1, 0, $domain & "\" & $username, $password) FileCopy("B:\Universe.def", $target_1, 1) If FileExists($target_1 & "\Universe.def") Then FileWriteLine($OpenLog, "File Universe.def has been copied to " & $target_1 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File Universe.def has failed to be copied to " & $target_1 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\SCHD1O.def", $target_1,1) If FileExists($target_1 & "\SCHD1O.def") Then FileWriteLine($OpenLog, "File SCHD1O.def has been copied to " & $target_1 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File SCHD1O.def has failed to be copied to " & $target_1 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\uxsetenv.bat", $target_2, 1) If FileExists($target_2 & "\uxsetenv.bat") Then FileWriteLine($OpenLog, "File uxsetenv.bat has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File uxsetenv.bat has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\U_ANTE_UPROC.bat", $target_2, 1) If FileExists($target_2 & "\U_ANTE_UPROC.bat") Then FileWriteLine($OpenLog, "File U_ANTE_UPROC.bat has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File U_ANTE_UPROC.bat has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\SCHD1O-Commands.lnk", $target_4, 1) If FileExists($target_4 & "\SCHD1O-Commands.lnk") Then FileWriteLine($OpenLog, "File SCHD1O-Commands.lnk has been copied to " & $target_4 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File SCHD1O-Commands.lnk has failed to be copied to " & $target_4 & ". Installation aborted." & @CRLF) Exit EndIf DriveMapDel("B:") DriveMapAdd("B:", $loc_2, 0, $domain & "\" & $username, $password) FileCopy("B:\uxsrsrv.sck", $target_2, 1) If FileExists($target_2 & "\uxsrsrv.sck") Then FileWriteLine($OpenLog, "File uxsrsrv.sck has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File uxsrsrv.sck has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\uxsrsrv.protocol", $target_2, 1) If FileExists($target_2 & "\uxsrsrv.protocol") Then FileWriteLine($OpenLog, "File uxsrsrv.protocol has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File uxsrsrv.protocol has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\u_fali01.txt", $target_2, 1) If FileExists($target_2 & "\u_fali01.txt") Then FileWriteLine($OpenLog, "File u_fali01.txt has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File u_fali01.txt has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf FileCopy("B:\useralias.txt", $target_2, 1) If FileExists($target_2 & "\useralias.txt") Then FileWriteLine($OpenLog, "File useralias.txt has been copied to " & $target_2 & " successfully." & @CRLF) Else MsgBox(0+16+0+0, $ScriptName, "FileCopy Failed. Quiting.") FileWriteLine($OpenLog, "File useralias.txt has failed to be copied to " & $target_2 & ". Installation aborted." & @CRLF) Exit EndIf DriveMapDel("B:") DriveMapAdd("B:", $loc_3, 0, $domain & "\" & $username, $password) DirCreate("F:\APPS\universe\tools") FileCopy("B:\*.*", $target_3 & "\*.*", 1) If FileExists($target_3) Then FileWriteLine($OpenLog, "Files have been copied to " & $target_3 & " successfully." & @CRLF) EndIf DriveMapDel("B:") ; Modify Files $find = "DU_NODE" $replace = $server $file1 = $target_1 & "\universe.def" $file2 = $target_1 & "\SCHD1O.def" $file3 = $target_2 & "\uxsetenv.bat" _ReplaceStringInFile($file1, $find, $replace, 0, 1) FileWriteLine($OpenLog, "File universe.def has been modified and is now configured for " & $server & "." & @CRLF) _ReplaceStringInFile($file2, $find, $replace, 0, 1) FileWriteLine($OpenLog, "File SCHD1O.def has been modified and is now configured for " & $server & "." & @CRLF) _ReplaceStringInFile($file3, $find, $replace, 0, 1) FileWriteLine($OpenLog, "File uxsetenv.bat has been modified and is now configured for " & $server & "." & @CRLF) ; Install Service $universe = "F:\APPS\universe\SCHD1O\mgr\uxstartup.bat" Run("CMD.EXE") WinWaitActive("C:\WINNT\system32\cmd.exe", "", 10) Send('INSTSRV univ_startup "C:\Program Files\resource kit\srvany.exe"') Send("{ENTER}") Sleep(1000) Send("EXIT") Send("{ENTER}") $OSBuild = @OSBuild If $OSBuild = "2195" Then RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\univ_startup\Parameters", "Application", "REG_SZ", $universe) FileWriteLine($OpenLog, $server & " is a Windows 2000 Server." & @CRLF) FileWriteLine($OpenLog, "Service univ_startup created successfully !" & @CRLF) ElseIf $OSBuild = "3790" Then RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\univ_startup\Parameters", "Application", "REG_SZ", $universe) FileWriteLine($OpenLog, $server & " is a Windows 2003 Server." & @CRLF) FileWriteLine($OpenLog, "Service univ_startup created successfully !" & @CRLF) EndIf ; Start Services $service_1 = "Univer$e SCHD1O_" & $server & "_universe" $service_2 = "Univer$e schd1oa" $service_3 = "Univer$e schd1od" $service_4 = "Univer$e schd1oe" Traytip("", "", 0) TrayTip($ScriptName, "Stopping Services ...", 100) _ServiceStop($service_1) _ServiceStop($service_2) _ServiceStop($service_3) _ServiceStop($service_4) Sleep(1000) TrayTip("", "", 0) TrayTip($ScriptName, "Starting Services ...", 100) _ServiceStart($service_1) _ServiceStart($service_2) _ServiceStart($service_3) _ServiceStart($service_4) TrayTip("", "", 0) FileWriteLine($OpenLog, "Services restarted successfully for " & $server & "." & @CRLF) ; Write Eventlog _LogEvent(0, 'The automatic installation of $u was completed successfully on ' & _Now() & ' by ' & $ScriptName & '.') ; Complete Log FileWriteLine($OpenLog, @CRLF & "Installation Successfull." & @CRLF & @CRLF) FileWriteLine($OpenLog, @CRLF & "Installation Ended: " & _Now() & "." & @CRLF & @CRLF) TrayTip($ScriptName, "Installation Completed!", 100) MsgBox(8192, $ScriptName, "Install Dollar U:" & @CRLF & @CRLF & "Congratulations! The installation of Dollar Universe has finished." & @CRLF & @CRLF & "You can find the log file in C:\TEMP\InstallDollarU.log")Error : Link to comment Share on other sites More sharing options...
enaiman Posted November 13, 2007 Share Posted November 13, 2007 I'm not sure about but it looks like the error might be located here: Send('INSTSRV univ_startup "C:\Program Files\resource kit\srvany.exe"') Maybe you need to specify a path for Instsrv (the path might be different on win 2003 than win 2000) or maybe srvany is located elsewhere. Play a little with this line and see what you get. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now