
win2k
Active Members-
Posts
59 -
Joined
-
Last visited
Everything posted by win2k
-
How to use this #include function?
win2k replied to win2k's topic in AutoIt General Help and Support
I edited my post above to include the link to where i got it from. -
How to use this #include function?
win2k replied to win2k's topic in AutoIt General Help and Support
I use scite and i did not write this, It was in the scripts and scrapts forum. Apparently it is able to find a key in the registry and modify its value but I can't seem to figure out how this script accomplishes this. You are right though, it is a pain to read through and figure out though. here is the link to where i got the script from. _RegSearchAndReplace seems to be what i could use. http://www.autoitscript.com/forum/index.ph...545&hl=Reg* -
Here is the code but well I am a brute force programmer (I am an MIS major and specialize in networking and suck at programming) and cannot figure out exactly how to use this to modify a key in the registry. All that I need to is find a key in the registry and modify it. If anyone could provide the correct syntax for this that would be sweet. Until then, I guess I am trying to figure it out on my own. ;Reg-Modify #region Doc: #region Doc: Notes ; Extends functionality of Registry functions #endregion Doc: Notes #region Doc: History #endregion Doc: History #region Doc: FunctionList ; _RegCreateKeys Creates a range of delimited subkeys ; _RegReRead Checks if the value is a registry key\val and if true returns that value. ; _RegRenameVal Renames registry $nam1 to $nam2 in key $Key ; _RegSearchAndReplace Scans through the registry replacing one string for another. ; _RegSetReset Updates the registry to either a set or reset value ; _RegSplit Splits a registry key+name string into key and name. ; _RegSwapVal Swaps registry $nam1 to $nam2 in key $Key ; _RegType Returns the string value of the registry type. ; _RegWriteSetRst Writes to the registry one of two values depending on $OkRst #endregion Doc: FunctionList #endregion Doc: #region Init: #region Init: Includes #include-once #include '..\PopGincl\PopG_MsgBox.au3' #include '..\PopGincl\PopG_String.au3' #include <GuiConstants.au3> #include <Constants.au3> #endregion Init: Includes #region Init: Absolute Constants Global Const $Hkcu ='HKEY_CURRENT_USER' Global Const $Hklm ='HKEY_LOCAL_MACHINE' Global Const $Hku ='HKEY_LOCAL_MACHINE' Global Const $Hkcr ='HKEY_CLASSES_ROOT' Global Const $REGGR_INDATA =1 Global Const $REGGR_INKEY =2 Global Const $REGGR_INVALUE =3 Global Const $RegBIN ='REG_BINARY' Global Const $RegDBE ='REG_DWORD_BIG_ENDIAN' Global Const $RegDWD ='REG_DWORD' Global Const $RegESZ ='REG_EXPAND_SZ' Global Const $RegFUL ='REG_FULL_RESOURCE_DESCRIPTOR' Global Const $RegLNK ='REG_LINK' Global Const $RegMSZ ='REG_MULTI_SZ' Global Const $RegNON ='REG_NONE' Global Const $RegREQ ='REG_RESOURCE_REQUIREMENTS_LIST' Global Const $RegRES ='REG_RESOURCE_LIST' Global Const $RegSZ ='REG_SZ' #endregion Init: Absolute Constants #region Init: Derived Constants Global Const $HkcrCls =$Hkcr&'\CLSID' Global Const $HkcuCp =$Hkcu&'\Control Panel' Global Const $HkcuCpDesk =$HkcuCp&'\Desktop' Global Const $HkcuEnv =$Hkcu&'\Environment' Global Const $HkcuSw =$Hkcu&'\Software' Global Const $HkcuSwGrv =$HkcuSw&'\Groove Networks, Inc.\Groove' Global Const $HkcuSwMs =$HkcuSw&'\Microsoft' Global Const $HkcuSwMsIe =$HkcuSwMs&'\Internet Explorer' Global Const $HkcuSwMsWin =$HkcuSwMs&'\Windows' Global Const $HkcuSwMsWinCv =$HkcuSwMsWin&'\CurrentVersion' Global Const $HkcuSwMsWinCvExp =$HkcuSwMsWinCv&'\Explorer' Global Const $HkcuSwMsWinCvPol =$HkcuSwMsWinCv&'\Policies' Global Const $HkcuSwMsWinCvPolExp =$HkcuSwMsWinCvPol&'\Explorer' Global Const $HkcuSwMsWinCvPolNet =$HkcuSwMsWinCvPol&'\Network' Global Const $HkcuSwMsWinCvPolSys =$HkcuSwMsWinCvPol&'\System' Global Const $HkcuSwMsWinNt =$HkcuSwMs&'\Windows NT' Global Const $HkcuSwMsWinNtCv =$HkcuSwMsWinNt&'\CurrentVersion' Global Const $HkcuSwMsWinNtCvExp =$HkcuSwMsWinNtCv&'\Explorer' Global Const $HkcuSwMsWinNtCvNet =$HkcuSwMsWinNtCv&'\Network' Global Const $HkcuSwPol =$HkcuSw&'\Policies' Global Const $HkcuSwPolMs =$HkcuSwPol&'\Microsoft' Global Const $HkcuSwPolMsWin =$HkcuSwPolMs&'\Windows' Global Const $HkcuSwPolMsWinSys =$HkcuSwPolMsWin&'\System' Global Const $HkcuSwPopG =$HkcuSw&'\PopG' Global Const $HklmSw =$Hklm&'\Software' Global Const $HklmSwCls =$HklmSw&'\Classes' Global Const $HklmSwGrv =$HklmSw&'\Groove Networks, Inc.\Groove' Global Const $HklmSwMs =$HklmSw&'\Microsoft' Global Const $HklmSwMsIe =$HklmSwMs&'\Internet Explorer' Global Const $HklmSwMsWin =$HklmSwMs&'\Windows' Global Const $HklmSwMsWinCv =$HklmSwMsWin&'\CurrentVersion' Global Const $HklmSwMsWinCvExp =$HklmSwMsWinCv&'\Explorer' Global Const $HklmSwMsWinNt =$HklmSwMs&'\Windows NT' Global Const $HklmSwMsWinNtCv =$HklmSwMsWinNt&'\CurrentVersion' Global Const $HklmSwMsWinNtCvWinl =$HklmSwMsWinNtCv&'\Winlogon' Global Const $HklmSwPopG =$HklmSw&'\PopG' Global Const $HklmSys =$Hklm&'\System' Global Const $HklmSysCcs =$HklmSys&'\CurrentControlSet' Global Const $HklmSysCcsCtl =$HklmSysCcs&'\Control' Global Const $HklmSysCcsSvc =$HklmSysCcs&'\Services' Global Const $HkuDef =$Hku&'\.DEFAULT' Global Const $HkuDefCp =$HkuDef&'\Control Panel' Global Const $HkuDefCpDesk =$HkuDefCp&'\Desktop' Global Const $HkuDefEnv =$HkuDef&'\Environment' Global Const $HkuDefSw =$HkuDef&'\Software' Global Const $HkuDefSwMs =$HkuDefSw&'\Microsoft' Global Const $HkuDefSwMsWinNt =$HkuDefSwMs&'\Windows NT' Global Const $HkuDefSwMsWinNtCv =$HkuDefSwMsWinNt&'\Current Version' Global Const $HkuDefSwMsWinNtCvNet =$HkuDefSwMsWinNtCv&'\Network' #endregion Init: Derived Constants #region Init: Autoit options #NoTrayIcon Opt('MustDeclareVars', True) Opt('RunErrorsFatal',False) #endregion Init: Autoit options #endregion Init: #region Run: #region Run: Test Harness #region Run: Test _RegSearchAndReplace ;~ Local $Hive=$HkcuSwPopG&'\test' ;~ RegWrite($Hive,'fred',$RegSZ,'joar') ;~ RegWrite($Hive,'andy',$RegSZ,'tom') ;~ RegWrite($Hive,'barbara',$RegSZ,'zebedee') ;~ RegWrite($Hive&'\a','fred',$RegSZ,'joar') ;~ RegWrite($Hive&'\a','andy',$RegSZ,'tom') ;~ RegWrite($Hive&'\a','barbara',$RegSZ,'zebedee') ;~ RegWrite($Hive&'\b','fred',$RegSZ,'joar') ;~ RegWrite($Hive&'\b','andy',$RegSZ,'tom') ;~ RegWrite($Hive&'\b','barbara',$RegSZ,'zebedee') ;~ RegWrite($Hive&'\b\c','fred',$RegSZ,'joar') ;~ RegWrite($Hive&'\b\c','andy',$RegSZ,'tom') ;~ RegWrite($Hive&'\b\c','barbara',$RegSZ,'zebedee') ;~ Local $OkData=True ;~ Local $OkValue=False ;~ Local $Srch='ar' ;~ Local $Repl='H' ;~ Local $Occ=0 ;~ Local $Case=0 ;~ ;ProgressOn('','') ;~ Local $ProgCnt=1 ;~ Local $ProgMax=10 ;~ _RegSearchAndReplace($Hive,$Srch,$Repl,$Occ,$Case,$OkData,$OkValue,$ProgCnt,$ProgMax) ;~ ;ProgressOff() #endregion Run: Test _RegSearchAndReplace #region Run: Test _RegSplit ;~ Local $Reg,$Key,$Name,$Val ;~ $Reg=$HklmSwMsWinCvExp&'\Abc=Def' ;~ _RegSplit($Reg,$Key,$Name,$Val) ;~ MsgBox(0,'_RegSplit test', '$Reg='&$Reg&@LF&'$Key='&$Key&@LF&'$Name='&$Name&@LF&'$Val='&$Val) ;~ Exit #endregion Run: Test _RegSplit #region Run: Test Gui ;~ Local $AppNam='Test Program for PopG_Array.au3' ;~ If WinExists($AppNam) Then _MsgBoxExit($mbfStop, $AppNam,'Already Running') ;~ AutoItWinSetTitle($AppNam) ;~ Local $msg,$Form1,$err,$new,$val1,$val2 ;~ Local $Key=$HkcuSw&'\PopG\temp' ;~ Local $Test_RegRenameVal,$Test_RegSwapVal,$Test_RegCreateKeys,$Test_RegWriteSetRst,$Test_RegType ;~ $Form1 = GUICreate($AppNam, 300, 200, 192, 125) ;~ GUICtrlCreateLabel('Select from the functions below to initiate a test. To verify actions you may wish to have the registry open.', 10, 10, 280, 34) ;~ $Test_RegRenameVal =GUICtrlCreateButton('$Test_RegRenameVal', 10, 40, 200, 21) ;~ GUICtrlSetTip($Test_RegRenameVal,'This test renames a registry string called "fred" to "joe"') ;~ Local $Test_RegSwapVal =GUICtrlCreateButton('$Test_RegSwapVal', 10, 70, 200, 21) ;~ GUICtrlSetTip($Test_RegSwapVal,'This test creates two entries Fred and Joe and then swaps their values.') ;~ Local $Test_RegCreateKeys =GUICtrlCreateButton('$Test_RegCreateKeys', 10, 100, 200, 21) ;~ GUICtrlSetTip($Test_RegCreateKeys,'Click me to add a 2dim array to another 2dim array. You will see three dialog boxes'&@LF&'1. TwoArr1 before'&@LF&'2. TwoArr2 before'&@LF&'3. TwoArr1 after'&@LF&'remember the first value is the number of entries') ;~ Local $Test_RegCreateKeys =GUICtrlCreateButton('$Test_RegCreateKeys', 10, 130, 200, 21) ;~ GUICtrlSetTip($Test_RegCreateKeys,'Click me to add a 2dim array to another 2dim array. You will see three dialog boxes'&@LF&'1. TwoArr1 before'&@LF&'2. TwoArr2 before'&@LF&'3. TwoArr1 after'&@LF&'remember the first value is the number of entries') ;~ Local $Test_RegType =GUICtrlCreateButton('$Test_RegType', 10, 130, 200, 21) ;~ GUICtrlSetTip($Test_RegType,'Click me to add a 2dim array to another 2dim array. You will see three dialog boxes'&@LF&'1. TwoArr1 before'&@LF&'2. TwoArr2 before'&@LF&'3. TwoArr1 after'&@LF&'remember the first value is the number of entries') ;~ Local $DoneBtn =GUICtrlCreateButton('$DoneBtn', 10, 160, 100, 21) ;~ GUISetState(@SW_SHOW) ;~ While True ;~ $msg = GuiGetMsg() ;~ Select ;~ Case $msg = $Test_RegRenameVal ;~ RegDelete($Key) ;~ RegWrite($Key,'fred',$RegSZ,'fredsvalue') ;~ _RegRenameVal($Key,'fred','joe') ;~ $err=@error ;~ $new=RegRead($Key,'joe') ;~ MsgBox($mbfInfo,'joes value is','"'&$new&'"'&' with an @error='&$err) ;~ RegDelete($Key) ;~ Case $msg = $Test_RegSwapVal ;~ RegDelete($Key) ;~ RegWrite($Key,'fred',$RegSZ,'fredsvalue') ;~ RegWrite($Key,'joe',$RegSZ,'joessvalue') ;~ _RegSwapVal($Key,'fred','joe') ;~ $err=@error ;~ $val1=RegRead($Key,'fred') ;~ $val2=RegRead($Key,'joe') ;~ MsgBox($mbfInfo,'_RegSwapVal result','freds value is "'&$val1&'"'&' and joes value is"'&$val2&'"'&' with an @error='&$err) ;~ RegDelete($Key) ;~ Case $msg = $Test_RegCreateKeys ;~ ;;; ;~ Case $msg = $Test_RegType ;~ ;;; ;~ Case $msg = $Test_RegWriteSetRst ;~ ;;; ;~ Case $msg = $GUI_EVENT_CLOSE Or $msg=$DoneBtn ;~ ExitLoop ;~ Case Else ;~ ;;;;;;; ;~ EndSelect ;~ WEnd ;~ Exit #region Run: Test _RegSetReset ;~ _RegSetReset #endregion Run: Test _RegSetReset #endregion Run: Test Gui #endregion Run: Test Harness #region Run: Functions: ; _RegSetReset Updates the registry to either a set or reset value Func _RegSetReset($Key,$Name,$Type,$SetVal,$OkReset=False,$OkSetDelete=False,$OkResetDelete=False,$RstVal='',$Desc='') Local $OldVal =RegRead($Key,$Name) Local $OldErr =@error Local $OldExt =@extended ; ;~ If $OldErr Then ;~ If $OldErr=1 Then ;Key not found ;~ SetError(1) ;~ Return False ;~ ElseIf $OldErr=-1 Then ;name not found - not an error in this program. ;~ SetError(0) ;~ ElseIf $OldErr=-2 Then ;unsupported type, so exit. ;~ SetError(2) ;~ Return False ;~ EndIf ;~ EndIf Local $OldType =_RegType($OldExt) ; ;~ If $OldType<>$Type Then ;~ If MsgBox($mbfStop,$AppTtl,'Registry type mismatch for' _ ;~ &@LF&'Key: '&$Key _ ;~ &@LF&'Name: '&$Name _ ;~ &@LF&'Old type was: '&$OldType _ ;~ &@LF&'New type is: '&$Type)<>$mbaOk Then ;~ SetError(3) ;~ Return False ;~ EndIf ;~ EndIf ; ;~ If $OkConfirm Then ;~ If MsgBox($mbfinfo,'Confirm','Ok to change: '_ ;~ &@LF&'Key: '&$Key _ ;~ &@LF&'Name: '&$Name _ ;~ &@LF&'to: '&$SetVal _ ;~ &@LF&'Purpose: '&$Desc)<>$mbaOk Then ;~ SetError(4) ;~ Return False ;~ EndIf ; ;~ RegDelete($Key,$Name) ; safety precaution. Trying to modify a value with a different (possibly wrong) type fails. But it could cause additional delays... ; Local $result If $OkReset Then If $OkResetDelete Then RegDelete($Key,$Name) $result=1 ;ignore errors Else $result=RegWrite($Key,$Name,$Type,$RstVal) EndIf Else If $OkSetDelete Then RegDelete($Key,$Name) $result=1 ;ignore errors Else $result=RegWrite($Key,$Name,$Type,$SetVal) EndIf EndIf Return $result EndFunc; _RegSetReset ; _RegSearchAndReplace Scans through the registry replacing one string for another. Func _RegSearchAndReplace($Hive,$Srch,$Repl,$Occ,$Case,$OkData,$OkValue,$ProgCnt=0,$ProgMax=0) Local $Idx,$Jdx,$Error Local $Key,$Val,$New,$Data,$Type $Jdx=1 While True $Val=RegEnumVal($Hive,$Jdx) If @error<>0 Then ExitLoop $Jdx=$Jdx+1 If $OkData Then $Data=RegRead($Hive,$Val) If @error=0 Then $Type=_RegType(@extended) If $Type=$RegSZ Then ; we c/should extend this to extended string types. $Data=StringReplace($Data,$Srch,$Repl,$Occ,$Case) RegWrite($Hive,$Val,$Type,$Data) EndIf EndIf EndIf If $OkValue Then $New=StringReplace($Val,$Srch,$Repl,$Occ,$Case) _RegRenameVal($Hive,$Val,$New) EndIf If $ProgCnt>=1 Then ProgressSet($ProgCnt/$ProgMax*100) $ProgCnt=$ProgCnt+1 If $ProgCnt>100 Then $ProgCnt=1 EndIf WEnd ; $Idx=1 While True $Key=RegEnumKey($Hive,$Idx) If @error<>0 Then ExitLoop $Idx=$Idx+1 _RegSearchAndReplace($Hive&'\'&$Key,$Srch,$Repl,$Occ,$Case,$OkData,$OkValue,$ProgCnt,$ProgMax) ; WEnd ; ;Not supported yet. ; If $OkKey Then ; $New=StringReplace($Key,$Srch,$Repl,1,$Case) ; _RegRenameKey($Hive&'\'&$Key,$New) ; EndIf EndFunc; _RegSearchAndReplace ; _RegRenameVal Renames registry $nam1 to $nam2 in key $Key ; @error - 1 if $nam1=$nam2 ; @error - 2 if $nam2 already exists ; @error - 3 if error reading $nam1 ; @error - 4 if error writing $nam2 Func _RegRenameVal($Key,$OldV,$NewV) If $OldV=$NewV Then SetError(1,0) Return False EndIf Local $NewD=RegRead($Key,$NewV) If Not @error Then; If new exists then leave it in place. SetError(2,0) Return False EndIf Local $OldD=RegRead($Key,$OldV) If @error Then SetError(3,0) Return False EndIf Local $Type=_RegType(@extended) RegWrite($Key,$NewV,$Type,$OldD) If @error Then SetError(4,0) Return False EndIf RegDelete($Key,$OldV) SetError(0,0) Return True EndFunc; _RegRenameVal ; _RegType Returns the string value of the registry type decimal constant, Func _RegType($idx) Local $Type Select Case $idx=$REG_NONE $Type='' Case $idx=$REG_SZ $Type=$RegSZ Case $idx=$REG_EXPAND_SZ $Type=$RegESZ Case $idx=$REG_BINARY $Type=$RegBIN Case $idx=$REG_DWORD $Type=$RegDWD Case $idx=$REG_DWORD_BIG_ENDIAN $Type=$RegDBE Case $idx=$REG_LINK $Type=$RegLNK Case $idx=$REG_MULTI_SZ $Type=$RegMSZ Case $idx=$REG_RESOURCE_LIST $Type=$RegRES Case $idx=$REG_FULL_RESOURCE_DESCRIPTOR $Type=$RegFUL Case $idx=$REG_RESOURCE_REQUIREMENTS_LIST $Type=$RegREQ Case Else SetError(1) EndSelect Return $Type EndFunc; _RegType ; _RegSwapVal Swaps registry $nam1 to $nam2 in key $Key ; @error - 1 if $nam1=$nam2 ; @error - 2 if error reading $nam1 ; @error - 3 if error reading $nam2 ; @error - 4 if error deleting $nam1 ; @error - 5 if error deleting $nam2 ; @error - 6 if error writing $nam1 ; @error - 7 if error writing $nam2 Func _RegSwapVal($Key,$nam1,$nam2) SetError(0) If $nam1=$nam2 Then SetError(1) Return False EndIf Local $val1=RegRead($Key,$nam1) If @error Then SetError(2) Return False EndIf Local $Type1=_RegType(@extended) Local $val2=RegRead($Key,$nam2) If @error Then SetError(3) Return False EndIf Local $Type2=_RegType(@extended) If $Type1<>$Type2 Then SetError(4) Return False EndIf If RegDelete($Key,$nam1) <> 1 Then SetError(5) Return False EndIf If RegDelete($Key,$nam2) <> 1 Then SetError(6) Return False EndIf If RegWrite($Key,$nam2,$Type1,$val1) <> 1 Then SetError(7) Return False EndIf If RegWrite($Key,$nam1,$Type1,$val2) <> 1 Then SetError(8) Return False EndIf Return True EndFunc;_RegSwapVal ; _RegSplit Splits a registry key\name=val string into key, name & value Func _RegSplit($RegKND,ByRef $Key,ByRef $Name, ByRef $dat) Const $KeyNamDlm='\' Const $NamValDlm='=' Local $LeftSl,$RightSl,$LeftEq,$RightEq _StringSplit2($RegKND,$NamValDlm,$LeftEq,$RightEq,1) _StringSplit2($LeftEq,$KeyNamDlm,$LeftSl,$RightSl,-1) $Key=$LeftSl $Name=$RightSl $dat=$RightEq EndFunc;_RegSplit ; _RegCreateKeys Creates a range of delimited subkeys Func _RegCreateKeys($base,$keys) Local $arr=StringSplit($keys,Opt('GUIDataSeparatorChar')) Local $Idx For $Idx=1 To $arr[0] RegWrite($base&'\'&$arr[$Idx]) Next EndFunc;_RegCreateKeys ; _RegWriteSetRst Writes to the registry one of two values depending on $OkRst Func _RegWriteSetRst($Key,$name,$Type,$SetVal,$OkRst=False,$RstTyp=0,$RstVal='_RegWriteSetRst-novalue',$VfySecs=0,$VfyMsg='') Local $TgtVal=$SetVal If $OkRst Then $TgtVal=$RstVal If $VfySecs>0 Then _MsgBoxExit($mbfInfo+$mbfOkCancel,'_RegWriteSetRst','In registry key '&$Key&' for value '&$name&@LF&'Setting to: '&$TgtVal&@LF&'Notes: '&$VfyMsg,$mbaCancel) RegDelete($Key,$name) ; delete first then we can create a clean value. If $OkRst Then ; typically admins can reset. Select Case $RstTyp=0 ; default: just delete ;;; ; which we have already done Case $RstTyp=1 ; reset to $RstVal If $RstVal='_RegWriteSetRst-novalue' Then _MsgBoxExit($mbfStop,'_RegWriteSetRst','Fatal error: no reset value specified!',$VfySecs) RegWrite($Key,$name,$Type,$TgtVal) EndSelect Else RegWrite($Key,$name,$Type,$TgtVal) EndIf EndFunc ; _RegReRead If the value read from the registry is registry key\val (ie begins with 'HKEY' then it reads and returns that value instead. Func _RegReRead($Key,$Val) $Val=RegRead($Key,$Val) If StringLeft(StringLower($Val),5)='hkey_' = 0 Then Return $Val _StringSplit2($Val,Opt('GUIDataSeparatorChar'),$Key,$Val,-1) Return _RegReRead($Key,$Val) ; recursive call! EndFunc #endregion Run: Functions #endregion Run:
-
Ok, yeah i read the sticky about that already. Well skimmed that sticky so im going to conclude that the "7th rule" is no keylogger posts allowed.
-
I dont really know which forum to post this in so I will post it here and hopefully not get yelled at. Anyways I was reading a post earlier about some keylogger post and they mentioned something about not breaking the "7th rule" Is there a post somewhere about these rules that i should read ?
-
Fark! your right. I guess thats another reason to have someone else check your code when something like that happens
-
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer","ObjecName","REG_SZ",$Domain_Name & $edmmt) Unless I am missing something here. I cant add a duplicate key by hand but auto will put one there.
-
ohhh thats been added to the favorites. Thanks
-
I tried that, it just adds a duplicate key. I cant delete the file and re-write it either, i just have to change its value. I am not sure if you can do that though.
-
SC.exe is having fits with changing the obj= of a service. If you changed the name in the registry you can still use SC to change the password. its really wierd
-
I know how to delete keys and write them to the registry, but is there a way to modify and existing key using auto it?
-
Actually, I think i figured out a way around the SC.exe failing. I can change the login name via the registry and then it stops the service, then use SC.exe to add the password and then start the service. Seems to be working ok
-
When i do this manually in the command window i just get an error returned saying [sC] ChangeServiceConfig Failed 87: The parameter is incorrect. The really wierd thing is that if i just go to the services window, log the service in and then set it back to local system, the script works fine. The only other thing i can think of to set up a service while logged out of the computer would be to somehow add keys to the registry. I dont have a clue as to how you do that though. I know how to change the login name for the service but not how to set the password via the registry
-
Ok, So this code just writes a key to the registry to set a depndency for a service. Well that works fine but when it comes to setting up the service to log on under a certain username, it will only work in windows 2003 and not windows 2000. Can anyone find anything wrong with this code ? I dont know if maybe microsoft changed the syntax of how you should use SC.exe from win2k and win2k3 or what. Any help would be great. #include <process.au3> #include <_NTServices.au3> HotKeySet("{END}", "Terminate") Dim $Domain_Name dim $comp_name=@ComputerName dim $temp dim $edmmt="\edmmtsadmin";This is just for the log in information Dim $Stopstatus Dim $Startstatus Const $service= "DVFaxNotifyServer" Const $pass = "password" const $dirPath = "C:\DV\MasPass\NetLogon" ;Change this variable to What you want the login name to be if you have to pull it from the registry $temp=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Reynolds&REYNOLDS\DV","Domain") ;This is changing the login name from either what you pulled from the registry or just the computer name If $temp="" Then $Domain_Name=$comp_name Else $Domain_Name=$temp endif ;setting up the registry keys RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer", "DependOnService") RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer","DependOnService","REG_MULTI_SZ","RPCSS" & @LF & "Fax" ) ;Brings up a command window in the background $rc = _RunDos("sc config " & $service & " start= auto" & " obj= " & $Domain_Name & $edmmt & " password= " & $pass ) $Stopstatus = _ServiceStop( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) $Startstatus = _ServiceStart( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) ;$rc = _RunDOS("net share NETLOGON /delete") ;$rc = _RunDos("net share NETLOGON="& $dirPath) Func Terminate() Exit 0 EndFunc
-
Which auto it command would be better?
win2k replied to win2k's topic in AutoIt General Help and Support
well this actually is part of a scheduled task so it runs when the user is logged out and just runs in the background, so i will have to check into that at work and test it out on our test servers. -
I just use this to start and stop windows services but i was wondering what would be better to use. #include <_NTServices.au3> $Stopstatus = _ServiceStop( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) $Startstatus = _ServiceStart( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) or #include <process.au3> $rc = _RunDos("sc stop DVFaxNotifyServer") $rc = _RunDos("sc start DVFaxNotifyServer") I was just wondering which snippet of code usually works better. I can add the code here for the #include files if needed.
-
How can I check the color of a pixel ?
win2k replied to ggirard's topic in AutoIt General Help and Support
Sure PixelGetColor(x,y) will do it, it returns the decimal value of the pixels color at the given x,y coordinate -
Autoit executables and Task Scheduler?
win2k replied to win2k's topic in AutoIt General Help and Support
_RunDos seems to be working perfect while logged out of the windows desktop, Thanks -
Autoit executables and Task Scheduler?
win2k replied to win2k's topic in AutoIt General Help and Support
Here ya go, Some of the code had to be changed for security reasons, and this script wont work if you run it as it, it would have to have some things changed for whatever services you run and where your domain name is located at in the registry #include <_NTServices.au3> HotKeySet("{END}", "Terminate") SplashTextOn("Service", "Please wait while DVFaxNotifyService has finished being setup") Dim $Domain_Name dim $comp_name=@ComputerName dim $temp dim $edmmt="\edmmtsadmin";This is just for the log in information Dim $Stopstatus Dim $Startstatus Const $service= "DVFaxNotifyServer" Const $pass = "12345" ;Change this variable to What you want the login name to be if you have to pull it from the registry $temp=RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\","Domain") ;This is changing the login name from either what you pulled from the registry or just the computer name If $temp="" Then $Domain_Name=$comp_name Else $Domain_Name=$temp endif RegDelete("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer", "DependOnService") RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DVFaxNotifyServer","DependOnService","REG_MULTI_SZ","RPCSS" & @LF & "Fax" ) Run("cmd.exe") sleep(2000) send("sc config " & $service & " start= auto" & " obj= " & $Domain_Name & $edmmt & " password= " & $pass ) send("{ENTER}") sleep(300) send("exit") send("{ENTER}") sleep(300) $Stopstatus = _ServiceStop( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) $Startstatus = _ServiceStart( _ToInternalServiceName("DVFaxNotifyServer") ) sleep(300) SplashOff() Func Terminate() Exit 0 EndFunc -
Does windows task scheduler and autoit ? I am trying to run a really simple script while logged out of my computer with the tast scheduler and it does all the registry editing fine but wont load up the cmd.exe and run a single line. Any thoughts ?
-
nm i figured it out
-
Yeah thats what i meant zero
-
yeah im using net share but for some reason its being picky about some things
-
I was wondering what would be the simplest way to share a folder using autoit?
-
I am trying to figure out a way to write a script to log into windows. For example, im working with Win2k and Win2k3. After you boot up, you hit the windows login screen, Is there a way to execute a script to automatically provide the login information ?