Sign in to follow this  
Followers 0
anystupidassname

noob needs assistance tshooting

10 posts in this topic

#1 ·  Posted (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!

;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 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#.......

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 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#.......

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Yup RunWait is the one you want. Had the same problems 7zipping output files from netsh and such.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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#.......

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Bad link, maybe you meant this: Entry 705917

Cool 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

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