Sign in to follow this  
Followers 0
andyvl

converting to autoIT

7 posts in this topic

I'm new to autoIt

How can I convert a script to autoIt?

let's say I have bellow script

;Enable "File and Printer Sharing for Microsoft Networks" functionality
   Shell '%comspec% /c @lanroot\nbtstat.exe -a %computername%|find /i "<20>"'
   If @ERROR<>0
      Shell '%comspec% /c echo'
      $index=-1
      While @ERROR=0
         $index=$index+1
         $nickey=EnumKey('hklm\software\microsoft\windows nt\currentversion\networkcards',$index)
         $nicid=ReadValue('hklm\software\microsoft\windows nt\currentversion\networkcards\'+$nickey,'servicename')
         If @error=0
            $lanmanserverkey='bind','export','route'
            For Each $i In $lanmanserverkey
               $lanmanserverkeyi=ReadValue('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i)
               If InStr($lanmanserverkeyi,$nicid)=0
                  Select
                     Case $i='bind'
                        WriteValue('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi+'\Device\NetBT_Tcpip_'+$nicid+'|','reg_multi_sz')
                     Case $i='export'
                        WriteValue('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi+'\Device\LanmanServer_NetBT_Tcpip_'+$nicid+'|','reg_multi_sz')
                     Case $i='route'
                        WriteValue('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi+'"NetBT" "Tcpip" "'+$nicid+'"|','reg_multi_sz')
                  EndSelect
               EndIf
            Next
         EndIf
      Loop
   EndIf

how can I alter it to autoit?

what neet to be changed?

(of somebody can translate this, I have a good reference cause I have a lot of 'registry-altering' scripts that need to be converted.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Here is a start (untested):

;Enable "File and Printer Sharing for Microsoft Networks" functionality
Run(@ComSpec & ' /c @lanroot\nbtstat.exe -a ' & @ComputerName & '|find /i "<20>"')
If @ERROR<>0
  Run(@ComSpec & ' /c echo')
  $index = -1
  While @ERROR=0
     $index += 1
     $nickey = RegEnumKey('hklm\software\microsoft\windows nt\currentversion\networkcards',$index)
     $nicid = RegRead('hklm\software\microsoft\windows nt\currentversion\networkcards\' & $nickey,'servicename')
     If @error=0
        $lanmanserverkey='bind','export','route'
        For $i In $lanmanserverkey
           $lanmanserverkeyi = RegRead('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i)
           If StringInStr($lanmanserverkeyi,$nicid)=0
              Switch $i
                 Case 'bind'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '\Device\NetBT_Tcpip_'& $nicid & '|','reg_multi_sz')
                 Case 'export'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '\Device\LanmanServer_NetBT_Tcpip_' & $nicid & '|','reg_multi_sz')
                 Case 'route'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '"NetBT" "Tcpip" "' & $nicid & '"|','reg_multi_sz')
              EndSelect
           EndIf
        Next
     EndIf
  WEnd
EndIf

Edited by weaponx

Share this post


Link to post
Share on other sites

what language is this written in? that would help for starters...

To be honnest, I don't know. I'm cleaning out/trying to improve a network from a friend.

A lot of it is done, except for 2 things.

On of them is the need for a script to easily turns on and off

file and printersharing

and

client for microsoft

on a computer. (this will be implemented in the startupscript)

Reason for the need, is that during certain period, the users are not allowed to use the supported options.

I'm looking now for over 2 days and I almost only find manual sollutions. But it is not an option to go to about 100 pc's and change the value manual.

so this needs to be automated.

so any help is appreciated.

Share this post


Link to post
Share on other sites

Here is a start (untested):

;Enable "File and Printer Sharing for Microsoft Networks" functionality
Run(@ComSpec & ' /c @lanroot\nbtstat.exe -a ' & @ComputerName & '|find /i "<20>"')
If @ERROR<>0
  Run(@ComSpec & ' /c echo')
  $index = -1
  While @ERROR=0
     $index += 1
     $nickey = RegEnumKey('hklm\software\microsoft\windows nt\currentversion\networkcards',$index)
     $nicid = RegRead('hklm\software\microsoft\windows nt\currentversion\networkcards\' & $nickey,'servicename')
     If @error=0
        $lanmanserverkey='bind','export','route'
        For $i In $lanmanserverkey
           $lanmanserverkeyi = RegRead('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i)
           If StringInStr($lanmanserverkeyi,$nicid)=0
              Switch $i
                 Case 'bind'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '\Device\NetBT_Tcpip_'& $nicid & '|','reg_multi_sz')
                 Case 'export'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '\Device\LanmanServer_NetBT_Tcpip_' & $nicid & '|','reg_multi_sz')
                 Case 'route'
                    RegWrite('hklm\system\currentcontrolset\services\lanmanserver\linkage',$i,$lanmanserverkeyi & '"NetBT" "Tcpip" "' & $nicid & '"|','reg_multi_sz')
              EndSelect
           EndIf
        Next
     EndIf
  WEnd
EndIf

hmm thanks. But it seems that the script is not working. (finally was able to test the original also, and it's not working either.

Any other way to do this?

Share this post


Link to post
Share on other sites

The original script is written in vbscript.

Does the original not work for you?

Share this post


Link to post
Share on other sites

I based myself on this script. looking for this values and if present delete them.

but I still have the options available

(and both file and printer sharing

and

client for microsoft )

need to be turned off

(prefered that this is done on ALL nics)

but really don't know how to handle this

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