Jump to content

PATH question


tqt129
 Share

Recommended Posts

I wrote a little script to run multiple programs at certain order. but i notice it wouldnt work for everyone because people instal ltheir programs on different path. is there a way to fix that?

this is the code. of course it works fine for me because thats my path but if someone use it, i would have ot change it =0

run ("C:\Program Files\NetzeroVoIP\NZVoice.exe", "", @SW_MINIMIZE)
sleep (8000)
run ("C:\Program Files\PDT\VoIPVoiceIntegration\VoIPVoice Integration.exe")
Link to comment
Share on other sites

you can use RegRead() to find the correct location... and if it exists

$temp_program = GetFile("\" & $process[$x])

Func GetFile($f1)
    RunWait(@ComSpec & ' /c ' & 'dir "' & @HomeDrive & $f1 & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE)
    Sleep(1000)
    Return FileReadLine(@TempDir & "\dir.txt", 1)
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

you can use RegRead() to find the correct location... and if it exists

$temp_program = GetFile("\" & $process[$x])

Func GetFile($f1)
    RunWait(@ComSpec & ' /c ' & 'dir "' & @HomeDrive & $f1 & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE)
    Sleep(1000)
    Return FileReadLine(@TempDir & "\dir.txt", 1)
EndFunc

8)

i dont understand what its going on with this code heh. can you take the time to educate me =/

Link to comment
Share on other sites

Ok

$Temp_file ; a "changeable" variable

$process[$x] ; is another ( in array format, but not necessary) can be just $process

GetFile() ; calls a function

"\" & $process[$x] ; add a slash before the process name ( ex... \notepad.exe )

... inside the function

RunWait(@ComSpec & ' /c ' & 'dir "' & @HomeDrive & $f1 & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE) ; runs and waits for the dos command Dir ( directory ) to search for the $fl ( same as "\" & $process[$x] )

/a :h /b /s ; says to look in sub-folders and just return the files found ( no header etc )

> "' & @TempDir & '\dir.txt" ; says output the info found into a text file in the users temp folder

Return FileReadLine(@TempDir & "\dir.txt", 1) ; returns the fist line read inside that temp file

ok????

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

i dont understand what its going on with this code heh. can you take the time to educate me =/

Valuater scripts on a higher metaphysical plane of existence than us mortals... :P

I think he left a couple steps out.

1. Do you have registry keys you could be checking for the location of these .exe files? If so, you could RegRead() the appropriate keys for the file locations.

2. I think the code example he posted uses the exe file's name (somehow put in the $process[$x] array variable) in a DIR /S search of the operator's entire home drive.

But, as I don't code on such higher planes, I could be wrong... :)

Edit: We have The Revelation According To Valuater! Cool!

P.S. All that step 2. stuff above is still not necesary if you can identify the right REG keys to get the path from.

Edited by PsaltyDS
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
Link to comment
Share on other sites

Ok

$Temp_file ; a "changeable" variable

$process[$x] ; is another ( in array format, but not necessary) can be just $process

GetFile() ; calls a function

"\" & $process[$x] ; add a slash before the process name ( ex... \notepad.exe )

... inside the function

RunWait(@ComSpec & ' /c ' & 'dir "' & @HomeDrive & $f1 & '" /a :h /b /s' & ' > "' & @TempDir & '\dir.txt"', '', @SW_HIDE) ; runs and waits for the dos command Dir ( directory ) to search for the $fl ( same as "\" & $process[$x] )

/a :h /b /s ; says to look in sub-folders and just return the files found ( no header etc )

> "' & @TempDir & '\dir.txt" ; says output the info found into a text file in the users temp folder

Return FileReadLine(@TempDir & "\dir.txt", 1) ; returns the fist line read inside that temp file

ok????

8)

hmm $Temp_file was not in the code you posted earlier, is it $temp_program you intend to type?

Link to comment
Share on other sites

Open up regedit.exe and go to "HKEY_LOCAL_MACHINE\SOFTWARE\". Check if you can

find the applications' names listed there and see if there are some keys that specifies

where they are installed. You then use this information in RegRead. Example for AutoIt :

$path = RegRead("HKLM\SOFTWARE\AutoIt v3\AutoIt", "InstallDir")
MsgBox(64, "", $path)
Link to comment
Share on other sites

no actually the second program will only work if the first program load.so i just put load time to make sure it loads

Quoting Valuator in post #2:

you can use RegRead() to find the correct location...

Quoting me from post #5:

1. Do you have registry keys you could be checking for the location of these .exe files? If so, you could RegRead() the appropriate keys for the file locations.

P.S. All that step 2. stuff above is still not necesary if you can identify the right REG keys to get the path from.

Quoting Helge from post #14:

Open up regedit.exe and go to "HKEY_LOCAL_MACHINE\SOFTWARE\". Check if you can

find the applications' names listed there and see if there are some keys that specifies

where they are installed. You then use this information in RegRead.

Do you see a pattern here?

I see a pattern here.

There just might be a pattern here... :)

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
Link to comment
Share on other sites

Quoting Valuator in post #2:

Quoting me from post #5:

Quoting Helge from post #14:

Do you see a pattern here?

I see a pattern here.

There just might be a pattern here... :)

I do have it on registry..sorry i didnt mention it earlier. it is in C:\NetZeroVoice for install path . HKEY_LOCAL_MACHINE\SOFTWARE\NetZeroVoIP

Edited by tqt129
Link to comment
Share on other sites

I do have it on registry..sorry i didnt mention it earlier. it is in C:\NetZeroVoice for install path . HKEY_LOCAL_MACHINE\SOFTWARE\NetZeroVoIP

Did you read my post? @ScriptDir = wherever the script is running, even after you complie it the macro still functions. You can do it from the registry, but this is much easier :)

Link to comment
Share on other sites

No sense in reinventing the wheel...

tqt129 shows a script that runs two files from two different folders. For your idea to

work the script would have to be placed in the same folder as both of the program-

files at the same time, making @ScriptDir magically return the correct path at the

right time, which I believe is pretty impossible...hmm, yep.

HKEY_LOCAL_MACHINE\SOFTWARE\NetZeroVoIP

What's the "valuename" ?
$path = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\NetZeroVoIP", "ValueNameHerePlease")
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...