Sign in to follow this  
Followers 0
vickerps

Problem with autoit-v3.2.0.1

4 posts in this topic

#1 ·  Posted (edited)

Hi

I have problems with Autoit-v3.2.0.1. I have a script that i written in Autoit-v3.1.0 and now that i have installed this new version it no longer works.

I think the problem is with autoit running the vbs script after it writes it.

I came to this conclusion by running the script then editing the script so that it does not rewrite the .vbs file just run the previously created ones. Then when when you run the script again it works.

Could it be somthing to do with the file close command not closing the file. I have tried tweaking it by putting a sleep(5000) between closing the file and running it but still no joy. anyone have any idea's

#INCLUDE <Process.au3>

NameChange("Paul")
IPCHANGE("110.1.1.1","255.255.255.0","110.1.1.254","Paul")

; ----------------------------------------------------------------------------
FUNC NameChange($ComputerName)

    SplashTextOn ( "", "Please Wait... Changing ComputerName",240, 85, -1, -1,1,"",18)
    Sleep(2000)     
            $Name = $ComputerName & "_Name.VBS"

            FileOpen ($Name,2)
            
            FileWrite($Name,'strComputer = "."' & @CRLF)
            FileWrite($Name,'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")' & @CRLF)
            FileWrite($Name,'Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")' & @CRLF)
            FileWrite($Name,'   For Each objComputer in colComputers' & @CRLF)
            FileWrite($Name,'       ObjComputer.Rename("' & $ComputerName & '")' & @CRLF)
            FileWrite($Name,'   Next' & @CRLF)
        
            FileClose ($Name)

            _RunDOS($ComputerName & "_Name.VBS")
    SplashOff()
ENDFUNC

FUNC IPCHANGE($I,$S,$G,$ComputerName)

    SplashTextOn ( "", "Please Wait... Changing IP",240, 85, -1, -1,1,"",18)
    Sleep(2000)                     
        $Network =$ComputerName & "_IP.VBS"
        
        FileOpen ($Network,2)
            
            FileWrite($Network,'strComputer = "."' & @CRLF)
            FileWrite($Network,'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")' & @CRLF)
            FileWrite($Network,'Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")' & @CRLF)
            FileWrite($Network,'    For Each objNetAdapter in colNetAdapters' & @CRLF)
            FileWrite($Network,'        IP = objNetAdapter.EnableStatic(Array("' & $I & '"),Array("' & $S & '"))' & @CRLF)
            FileWrite($Network,'        Gateway = objNetAdapter.SetGateways(Array("' & $G & '"),Array(1))' & @CRLF)
            FileWrite($Network,'    Next' & @CRLF)

        FileClose ($Network)

    _RunDOS($ComputerName & "_IP.VBS")

    SplashOff() 
ENDFUNC
Edited by vickerps

Share this post


Link to post
Share on other sites



Can't test because the PC i am on does not have AutoIt , but it might help to know that Autoit now natively supports COM. This means that you most likely would not even need to call a VBS.


HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

Share this post


Link to post
Share on other sites

You are not using fileopen and fileclose correctly

$handle = FileOpen ($Name,2)
            
            FileWrite($handle,'strComputer = "."' & @CRLF)
            FileWrite($handle,'Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")' & @CRLF)
            FileWrite($handle,'Set colComputers = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")' & @CRLF)
            FileWrite($handle,' For Each objComputer in colComputers' & @CRLF)
            FileWrite($handle,'     ObjComputer.Rename("' & $ComputerName & '")' & @CRLF)
            FileWrite($handle,' Next' & @CRLF)
        
            FileClose ($handle)

Share this post


Link to post
Share on other sites

Thanks lads for your replies

Jon that works great thanks.

So can this be done directly through autoit now using COM. I am no programer and i am currently reading the websites it mentions in the help file about using the COM side of autoit but i think it going to take some time.

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