anystupidassname Posted October 1, 2009 Share Posted October 1, 2009 (edited) Hi all, Any body have some tips for tshooting where a script is failing? This is skipping to the end and just showing the last msgbox... (Time for a beer) I made the mistake of writing it all first thinking I could tshooting it after but I guess it is better to go line by line? Any assistance would be much appreciated! expandcollapse popup;check for telltale RegRead("hklm\software\","lam") If @Error > 0 Then MsgBox(0, "", "1") FileInstall("QRes.exe",@TempDir,1) FileInstall("WUInstall.exe",@TempDir,1) MsgBox(0, "", "2") If @OSBuild < 3791 Then $wl = RegRead("hklm\software\microsoft\windows\currentversion\setup","Installation Sources") FileCopy($wl"\I386","%systemroot%\I386",9) EndIf MsgBox(0, "", "3") ;disable prelogon screensaver RegWrite("hku\.default\control panel\desktop\","screensaveractive","REG_DWORD","0") ;set resolution Run(@ComSpec & " /c " & @TempDir & "qres.exe /x:1024 /c:32 /r:85") ;add lam user Run(@ComSpec & " /c " & "net user lam **ZAPPED** /add") Run(@ComSpec & " /c " & "net localgroup Users lam /del") Run(@ComSpec & " /c " & "net localgroup Administrators lam /add") Run(@TempDir & "WUInstall.exe /install") ;disable UAC RegWrite("HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\","EnableLUA","REG_DWORD","2") ;remove IE ESC RegWrite("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}","IsInstalled","REG_DWORD","0") RegWrite("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}","IsInstalled","REG_DWORD","0") RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents","iehardenadmin","REG_DWORD","0") RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup\OC Manager\Subcomponents","iehardenuser","REG_DWORD","0") ;disable firewall RegWrite("HKLM\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile","EnableFirewall","REG_DWORD","0") RegWrite("HKLM\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile","EnableFirewall","REG_DWORD","0") Run(@ComSpec & " /c " & "sc config SharedAccess start= disabled") Run(@ComSpec & " /c " & "netsh firewall set opmode mode=disable profile=all") Run(@ComSpec & " /c " & "net stop SharedAccess") ; Run the following command lines: (from an elevated command line window.) Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenLMSettings") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenUser") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenAdmin") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenMachineNow") ;security center disable RegWrite("HKLM\SYSTEM\ControlSet001\Services\wscsvc","Start","REG_DWORD","4") ;disable system restore RegWrite("HKLM\SOFTWARE\Policies\Microsoft\Windows NT","DisableConfig","REG_DWORD","1") ;simple file sharing RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Lsa\","forceguest","REG_DWORD","0") ;set windows update manual RegWrite("HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU","NoAutoUpdate","REG_DWORD","0") RegWrite("HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU","AUOptions","REG_DWORD","2") ;logon type + screensaver RegWrite("HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\","LogonType","REG_DWORD","0") RegWrite("HKLM\\Software\Microsoft\Windows\CurrentVersion\Policies\System\","DisableCAD","REG_DWORD","1") ;enable rdp RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server","fDenyTSConnection","REG_DWORD","0") ;remove IE ESC RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","IEHarden","REG_DWORD","0") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","UNCAsIntranet","REG_DWORD","0") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","AutoDetect","REG_DWORD","1") RegDelete("HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}") RegDelete("HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}") RegDelete("HKCU\Software\Microsoft\Internet Explorer\Main","First Home Page") ;;;MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\BackInfo=1,C:\BackInfo.exe ;unhide hidden and system files and show extensions RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","superhidden","REG_DWORD","1") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","hidden","REG_DWORD","1") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","hidefileext","REG_DWORD","0") ;set best performance RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\","VisualEffects","REG_DWORD","2") ;server startup wizard disable RegWrite("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Setup\Welcome","srvwiz","REG_DWORD","0") ;classic systray RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer","EnableAutoTray","REG_DWORD","0") ;create telltale RegWrite("hklm\software\","lam","REG_SZ","deleteme") ;prompt to reboot and login as lam MsgBox(16,"Logout","Please log out, log back in as "lam" and run this a second time") Shutdown(16) Else ;;;MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\BackInfo=1,C:\BackInfo.exe ;set resolution Run(@ComSpec & " /c " & @TempDir & "qres.exe /x:1024 /c:32 /r:85", "") ;disable IE ESC RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","IEHarden","REG_DWORD","0") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","UNCAsIntranet","REG_DWORD","0") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap","AutoDetect","REG_DWORD","1") RegDelete("HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}") RegDelete("HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}") RegDelete("HKCU\Software\Microsoft\Internet Explorer\Main","First Home Page") ;server startup wizard disable RegWrite("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Setup\Welcome","srvwiz","REG_DWORD","0") ;set best performance RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\","VisualEffects","REG_DWORD","2") ;unhide hidden and system files and show extensions RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","superhidden","REG_DWORD","1") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","hidden","REG_DWORD","1") RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced","hidefileext","REG_DWORD","0") ;classic systray RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer","EnableAutoTray","REG_DWORD","0") ;delete telltale RegDelete("hklm\software\","lam") EndIf ;If @error Then ; MsgBox(0, "Failed", "Sum Ting Wong!") ; Exit ;Else MsgBox(64, "Time for a beer", "The tool thinks everything went well and you're now done..." & @LF & "Thank you for abusing this tool") ;EndIf Exit Edited October 1, 2009 by anystupidassname This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#....... Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 1, 2009 Share Posted October 1, 2009 If you uncomment that EndIf at the end of the code, it'll probably work. I don't know if it'll work right though.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
anystupidassname Posted October 1, 2009 Author Share Posted October 1, 2009 (edited) If you uncomment that EndIf at the end of the code, it'll probably work. I don't know if it'll work right though..If I uncomment an EndIf, I'll have an EndIf without an If... I do not like green eggs and ham. Thanks anyway. Edited October 1, 2009 by anystupidassname This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#....... Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2009 Share Posted October 1, 2009 The MsgBox() method is annoying, as I'm sure you've found. I like something more like this: #include <File.au3> Global $sLogFile = @ScriptDir & "\" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC & ".log" ; do something x _FileWriteLog($sLogFile, "Did something x") ; do something y _FileWriteLog($sLogFile, "Did something y") ; do something z _FileWriteLog($sLogFile, "Did something z") There is also a debugging log function that opens an instance of Notepad and puts all the lines there, so you can follow along as it runs: #include <Debug.au3> _DebugSetup ("Test") ; do something x _DebugOut("Did something x") ; do something y _DebugOut("Did something y") ; do something z _DebugOut("Did something z") What I don't like about that is no time tagging, so I would modify it like this: #include <Debug.au3> _DebugSetup ("Test") ; do something x Sleep(Random(10, 1000, 1)) _DebugLogging("Did something x") ; do something y Sleep(Random(10, 1000, 1)) _DebugLogging("Did something y") ; do something z Sleep(Random(10, 1000, 1)) _DebugLogging("Did something z") Func _DebugLogging($sText, $bActivate = False) Local $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY Local $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC Local $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sText _DebugOut($sMsg, $bActivate) EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Zedna Posted October 1, 2009 Share Posted October 1, 2009 Try to use RunWait() instead of Run(). Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
omikron48 Posted October 2, 2009 Share Posted October 2, 2009 Yup RunWait is the one you want. Had the same problems 7zipping output files from netsh and such. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted October 2, 2009 Share Posted October 2, 2009 If I uncomment an EndIf, I'll have an EndIf without an If... I do not like green eggs and ham. Thanks anyway.Oh sorry, I didn't catch the EndIf after the ;delete telltale code.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
anystupidassname Posted October 5, 2009 Author Share Posted October 5, 2009 The MsgBox() method is annoying, as I'm sure you've found. I like something more like this: #include <File.au3> Global $sLogFile = @ScriptDir & "\" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC & ".log" ; do something x _FileWriteLog($sLogFile, "Did something x") ; do something y _FileWriteLog($sLogFile, "Did something y") ; do something z _FileWriteLog($sLogFile, "Did something z") There is also a debugging log function that opens an instance of Notepad and puts all the lines there, so you can follow along as it runs: #include <Debug.au3> _DebugSetup ("Test") ; do something x _DebugOut("Did something x") ; do something y _DebugOut("Did something y") ; do something z _DebugOut("Did something z") What I don't like about that is no time tagging, so I would modify it like this: #include <Debug.au3> _DebugSetup ("Test") ; do something x Sleep(Random(10, 1000, 1)) _DebugLogging("Did something x") ; do something y Sleep(Random(10, 1000, 1)) _DebugLogging("Did something y") ; do something z Sleep(Random(10, 1000, 1)) _DebugLogging("Did something z") Func _DebugLogging($sText, $bActivate = False) Local $sDateNow = @YEAR & "-" & @MON & "-" & @MDAY Local $sTimeNow = @HOUR & ":" & @MIN & ":" & @SEC & "." & @MSEC Local $sMsg = $sDateNow & " " & $sTimeNow & " : " & $sText _DebugOut($sMsg, $bActivate) EndFunc I've started using _FileWriteLog and it seems to be working out for me. Thank you! This signature is computer generated, nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#nothing can go wron#....... Link to comment Share on other sites More sharing options...
TurionAltec Posted October 5, 2009 Share Posted October 5, 2009 Run(@ComSpec & " /c " & @TempDir & "qres.exe /x:1024 /c:32 /r:85") Run(@ComSpec & " /c " & "net user lam **ZAPPED** /add") Run(@ComSpec & " /c " & "net localgroup Users lam /del") Run(@ComSpec & " /c " & "net localgroup Administrators lam /add") Run(@ComSpec & " /c " & "sc config SharedAccess start= disabled") Run(@ComSpec & " /c " & "netsh firewall set opmode mode=disable profile=all") Run(@ComSpec & " /c " & "net stop SharedAccess") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenLMSettings") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenUser") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenAdmin") Run(@ComSpec & " /c " & "Rundll32 iesetup.dll, IEHardenMachineNow") Run(@ComSpec & " /c " & @TempDir & "qres.exe /x:1024 /c:32 /r:85", "")NONE of these commands are internal to CMD.exe and therefore NONE of them need '"@comspec & " /c "' in their run statements. As mentioned you probably want runwait.Also this is a cool alternative for debugging instead of just a log file:http://www.autoitscript.com/forum/index.php?showtopic=95595&st=0&p=705917&#entry705917 Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 6, 2009 Share Posted October 6, 2009 Also this is a cool alternative for debugging instead of just a log file:http://www.autoitscript.com/forum/index.php?showtopic=95595&st=0&p=705917&#entry705917Bad link, maybe you meant this: Entry 705917Cool idea, but requires an extra viewer. Not hard to get, but not included so you have to ensure it's available on the machine. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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