Jump to content

Run()


Recommended Posts

Yep, thats the nature of variables. Also you can pass the variable to a function just as you did above. When calling that function, pass whatever variable you want (which will ultimately end up in the Run command).

Looking at code almost makes it easier to explain;

$var1 = "notepad.exe"
MsgBox(0, "", "After you click OK, notepad will run")
Function($var1)

$var2 = "cmd"
MsgBox(0, "", "After you click OK, cmd prompt will open")
Function($var2)


Func Function($Variable)
    
    Run($Variable)
    
EndFunc

EDIT Whoops forgot to welcome you to the forum!

Edited by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

RUN($Variable)

This may work, but not the other way around. "Filename" is a required item.

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Link to comment
Share on other sites

$var = "notepad"

MyFunc($var)

Func MyFunc($var)

Run($var)

endfuncoÝ÷ Ù8Z·
+Æ®¶­sbb33c´äÔTTDBÒuT7G&Ä7&VFTVFBgV÷C´fÆRæÖRgV÷C²Â#ÂÂ3Â#¢b33c´äÔU$TBÒuT7G&Å&VBb33c´äÔTTDB¤×gVæ2b33c´äÔU$TB ¤gVæ2×gVæ2b33c´äÔU$TB  'Vâb33c´äÔU$TB ¤VæDgVæ0

That doesn't. I'm positive I'm entering "notepad" in the correct field.

Any idea why?

Error: Unable to execute external program.

Access is denied.

Link to comment
Share on other sites

I don't know why exactly that isn't working.... this works for me;

$NAMEREAD = "notepad"
MyFunc($NAMEREAD)

Func MyFunc($NAMEREAD)
    
    Run($NAMEREAD)
    
EndFunc

Try to use some debugging, throw in a msgbox (or consolewrite) before the run function to check the value of $nameread, even an extra space could throw it off. I don't know why it would be saying access denied... are you running vista by chance? Does it change anything to run the script as an admin, or to change the workingdir of the run command?

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

I don't know why exactly that isn't working.... this works for me;

$NAMEREAD = "notepad"
MyFunc($NAMEREAD)

Func MyFunc($NAMEREAD)
    
    Run($NAMEREAD)
    
EndFunc

Try to use some debugging, throw in a msgbox (or consolewrite) before the run function to check the value of $nameread, even an extra space could throw it off. I don't know why it would be saying access denied... are you running vista by chance? Does it change anything to run the script as an admin, or to change the workingdir of the run command?

XP. I'm writing a section to do some debugging atm.

Edit: Checked the value while running, turns out it's either not reading correctly or not saving correctly. Probably a mistake somewhere.

Edit2: Yup, turned out I made a mistake. Thanks!

Edited by Saroset
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...