You are here

passing variables between programs?

20 posts / 0 new
Last post
Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
passing variables between programs?

what's the best way to pass a variable between different programs? I want NSIS to see which drives are HDD and not solid state and have it pass that information to my AutoIt program.

Shawn Faucher
Shawn Faucher's picture
Offline
Last seen: 13 years 5 months ago
Developer
Joined: 2007-10-23 22:14
environment variables?

If you're running the autoit program from the NSIS program you can pass it in an environment variable...

formerly rayven01

Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
how

how would i do that? i think in autoit i can do EnvGet() but i'm not sure about nsis

Shawn Faucher
Shawn Faucher's picture
Offline
Last seen: 13 years 5 months ago
Developer
Joined: 2007-10-23 22:14
Example
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("name", "value").r0'

formerly rayven01

digitxp
digitxp's picture
Offline
Last seen: 11 years 4 months ago
Joined: 2007-11-03 18:33
I had

a familiar problem, but my solution was an INI file.

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 11 years 11 months ago
Joined: 2006-12-12 12:00
I'd say: If one program

I'd say:
If one program starts the other, use command line.
Otherwise memory mapped files are probably the best solution, but in some languages (NSIS) not comfortable to use. Maybe windows messages would be better?

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
I would go with an env var

I would go with an env var or an INI file. INI file might be easier to implement if you're not comfortable with setting/reading env vars yet.

m2
Offline
Last seen: 11 years 11 months ago
Joined: 2006-12-12 12:00
One note: sometimes it may

One note: sometimes it may be insignificant, but using an .ini file is slow, especially when you constantly reread it. You can help Windows optimize it though. Create the file with "temporary" attribute. It will not be written to disk, but kept in cache instead (if it fits).

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
help

ok i tried to make the env var work, but when i tried to have autoit recieve it, all it did was return the full path of the autoit exe. and i'm not sure how i would do the ini since the variable i'm using has multiple strings in it. I know i'm kinda asking a lot but is there any way i can get some more detailed help, as i'm not really experienced enough to do this it seems? this is for JkDefrag Portable. All i want is to do that ${GetDrives} "HDD" command in NSIS, nsis launches my autoit exe, and i want Autoit to compare the drives to see if they are a HDD or not, since autoit can't detect hdd vs solid state. Thanks a bunch for any help.

Shawn Faucher
Shawn Faucher's picture
Offline
Last seen: 13 years 5 months ago
Developer
Joined: 2007-10-23 22:14
Env variable troubleshooting

The easiest way to troubleshoot environment variables on the NSIS side is to change the launcher to run "c:\windows\system32\cmd.exe" instead of the real executable. That'll pop up a command window and you can do "set" and see if the variables you want are correct. If they aren't what you expect, take a closer look at the system call you made to set the environment variable in the launcher.. that pretty much has to be the culprit.

Never used AutoIt so I'm not much help on that side.

formerly rayven01

m2
Offline
Last seen: 11 years 11 months ago
Joined: 2006-12-12 12:00
Some time ago I wrote a

Some time ago I wrote a program for this purpose. It's very raw, but works better than cmd.exe.
You can get it form here.
2mods: I don't think I still have it's sources, for sure not in the place I'm in now. If you want to, delete the link.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

John T. Haller
John T. Haller's picture
Online
Last seen: 13 min 1 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Command line

Just pass it in as a delimited command line parameter. So, the NSIS script detects C, D and F as hard drives, it starts up your script as SciptName.exe C.D.F or something similar. Or pass them as unique variables (SciptName.exe C D F) if the scipting language makes it easier to parse them that way

Sometimes, the impossible can become possible, if you're awesome!

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
You don't need NSIS for this

You don't need NSIS for this at all.

NSIS types [${GetDrives}] -
floppy
hard
CD
network
ram

AutoIt types [DriveGetDrive] -
All
CD
removeable (=FDD)
fixed (=HDD)
network
ram
unknown

It's the same thing. Just use the AutoIt functions. It also has DriveGetType and DriveStatus if you need them.

Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
no

no, because removable refers to a removable hdd or a flash drive. and i'm sure fixed could potentially be a solid state drive. i know that the getdrives in nsis sees flash drives as fdd not hdd.

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
I'm pretty certain that both

I'm pretty certain that both NSIS and AutoIt use the windows API to retrieve results here...so they should be the same, even if they're called something a little different. Did you actually try it out and see if both methods give you the same results?

Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
I'm dumb

wow, i wish i would have tested this out before.... you're right. autoit sees a removable hard drive as "fixed". well i guess at least now i know how to pass information through the command line Smile

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
Ha, no big deal. Check out

Ha, no big deal. Check out the DllCall function in AutoIt, and the System plugin in NSIS. They are used to directly call Windows API functions. The WinAPI function that is used is called GetDriveType(A/W) -

http://msdn2.microsoft.com/en-us/library/aa364939.aspx

There's a link on that page to another function to determine if a drive is a USB type drive, but it's a little beyond me to get it to work right now.

Travis Carrico
Offline
Last seen: 14 years 2 months ago
Developer
Joined: 2006-10-22 00:30
yay

ok I got it! i passed all the drive letters as command line parameters. Thanks a bunch everyone

digitxp
digitxp's picture
Offline
Last seen: 11 years 4 months ago
Joined: 2007-11-03 18:33
I'm afraid to say it...

But what about the registry... AAAAAHHHHH! I said it!!!!!!!!:jawdrop:!
Somebody, tape my mouth shut, I will not tolerate myself asking to save settings in the registry! AAAAAHHHH!!! I said it again!!!!!!! *faints*

Insert original signature here with Greasemonkey Script.

m2
Offline
Last seen: 11 years 11 months ago
Joined: 2006-12-12 12:00
Not bad. Better than files.

Not bad. Better than files. One minor drawback (actually files also have it): If your program is terminated or crashes - you'll leave some rubbish on the host machine.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

Log in or register to post comments