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.
New: DesktopSnowOK (Jan 6, 2025), Platform 29.5.3 (Jun 27, 2024)
1,100+ portable packages, 1.1 billion downloads
No Ads Nov/Dec/Jan!, Please donate today
If you're running the autoit program from the NSIS program you can pass it in an environment variable...
formerly rayven01
how would i do that? i think in autoit i can do EnvGet() but i'm not sure about nsis
formerly rayven01
a familiar problem, but my solution was an INI file.
Insert original signature here with Greasemonkey Script.
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
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.
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
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.
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
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
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 waySometimes, the impossible can become possible, if you're awesome!
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.
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.
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?
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
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.
ok I got it! i passed all the drive letters as command line parameters. Thanks a bunch everyone
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.
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