Jump to content

New


TheRunner
 Share

Recommended Posts

BTW, the keyboard shortcut for the Windows start menu key is CTRL-ESC, if that's any help to the whole conversation.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks!

Sorry got caught up in doing something else

I am trying to set up a script that will run a regedit delete any "oracle" from there then add it back in using a reg file i have then change the environment variables path to what I have set or adding to the path.

Any ideas ?

Im still learnin how to get the controls to work and to click on what i want xD

Thanks!

Link to comment
Share on other sites

Thought I would share what I got done.

dim $a1[25]
dim $string = ""


$var = EnvGet("PATH")
MsgBox(4096, "Path variable is:", $var)


$a1 = StringSplit($var, ';', 1)

For $i = 0 to $a1       
    if StringCompare($i,'0') <> 0 then
        $results = StringInStr($i, "ITEM TO FIND")
        if $results <> 0 Then
            $i = ""
        Else            
            $string = $string  & $i 
            MsgBox(0,"String:",$string) 
            $string = $string & ";"
        EndIf       
    EndIf           
   Next

$result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", $string)
If $result = 1 Then
    EnvUpdate()
EndIf
Edited by TheRunner
Link to comment
Share on other sites

Thought I would share what I got done.

Looks like you're off to a good start!

A bit of a problem in the loop though...

The first element of array $a1 (which is $a1[0]) will contain the total number of elements in the array, so your loop ought to begin:

For $i = 1 to $a1[0]

Since you're now starting at 1, you can dispense with the "$i <> 0" test...

Edit: Inside the loop, you'll be wanting to deal with the actual data elements of your array by referencing "$a1[$i]". Stick an "#Include <Array.au3>" at the top of your script, and an "ArrayDisplay($a1)" right after your StringSplit(). For debugging purposes, those two statements will give you a good idea at how your array is constructed, and what it contains.

Edited by Spiff59
Link to comment
Share on other sites

Looks like you're off to a good start!

A bit of a problem in the loop though...

The first element of array $a1 (which is $a1[0]) will contain the total number of elements in the array, so your loop ought to begin:

For $i = 1 to $a1[0]

Since you're now starting at 1, you can dispense with the "$i <> 0" test...

Edit: Inside the loop, you'll be wanting to deal with the actual data elements of your array by referencing "$a1[$i]". Stick an "#Include <Array.au3>" at the top of your script, and an "ArrayDisplay($a1)" right after your StringSplit(). For debugging purposes, those two statements will give you a good idea at how your array is constructed, and what it contains.

Hey Thanks :),

Working on it now, and that _ArrayDisplay helps alot tx ^^

Ill post my final version of this later today ;)

-Runner

Link to comment
Share on other sites

Question

I would like to save something that is hiding such as

run(notepad.exe, @sw_hide)

close and save notepad as test.txt

but if its hiding it wont let me so far...is it not possible ?

also if the name has a space like this

Title: Registry Editor

ControlSend("[Class:Registry Editor]","","","!N") -- my code atm, this won't press "no"

How should it be?

My idea atm is to have everything hidden, meaning they double click the exe and it does everything it needs to do without them seeing anything.

If not then owell and life moves on lol ;)

Edited by TheRunner
Link to comment
Share on other sites

Ok well here it is ;)

Mostly design for what I am doing but mb someone can have some use for it, any pointers though that could help the script out or do what I orginally wanted (everything hidden) that would rock.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         The Runner

 Script Function:
    Remove oracle from registry then add new version to registry and update the environment variable

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#Include <Array.au3>

dim $a1[25]
dim $string = ""
dim $regFile = "The Registry File Path and name of the file"
dim $count = 0

$var = RegRead ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","Path") ; Path for environment variable

; Delete Oracle from Registry

$Reg = RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Oracle")
if $Reg = 1 Then
    MsgBox(0,"Delete","Oracle has been deleted")
Else
    MsgBox(0,"Delete Failed", "Oracle does not exist")
EndIf

; Put Oracle back in with correct version
; Shows the CMD

Run("cmd.exe")
WinWait("[CLASS:ConsoleWindowClass]")
Send($regFile&"{ENTER}")
sleep(1000)
Send("!y")
sleep(1000)
send("{ENTER}")
sleep(500)
Send("Exit{ENTER}")
sleep(1000)

; Get the string from the Registry Path then parse it (;) 
$a1 = StringSplit($var, ';', 1)


for $j = 1 to $a1[0]
    $count = $count + 1
Next

For $i = 1 to $a1[0]
    $results1 = StringInStr($a1[$i], "Possible version or what u wish to look for")
    $results2 = StringInStr($a1[$i], "ORACLE_9")
    $results3 = StringInStr($a1[$i], "ORACLE_8")    
    if $results1 <> 0 Then
        $a1[$i] = ""        
    ElseIf $results2 <> 0 Then
        $a1[$i] = ""
    ElseIf $results3 <> 0 Then
        $a1[$i] = ""
    Else        
        $string = $string  & $a1[$i]
        if $i <> $count Then
            $string = $string & ";"
        EndIf   
        EndIf               
Next

$file = FileOpen("file to open",0) ; what you want to add to the environment variable path.
$data = FileReadLine($file)

$string = $string & $data ; Add to your string

FileClose($file)

$result = RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "Path", "REG_EXPAND_SZ", $string) ; Add it
If $result = 1 Then
    EnvUpdate()
EndIf

#cs
; Make sure you can connect to the oracle DB, that is if u have :) so this part is just commented out.
Run("cmd.exe")
sleep(500)
Send("tnsping DB{enter}")
sleep(500)
Send("exit{ENTER}")
#ce
Edited by TheRunner
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...