#1 25 Jan 2020 09:04

Rekrul
Member
Registered: 17 Apr 2016
Posts: 71

Win7-10: Can scripts echo to a file in the root of the C drive?

I still have XP. I'm writing a script that I plan to distribute and it lets users customize some of the options. I'd like to offer the option to save the settings to a file so that it always loads up with the same settings, however the only way to not require the user to make sure that the settings file is in the same directory as the script is to save them to a consistent location and the only location you can be absolutely 100% sure of finding on every Windows machine is the C drive.

Will Windows allow a script to redirect Echo commands to a text file in the root of C in Win7-10, or will some new security restriction prevent that?

Offline

#2 25 Jan 2020 19:37

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 180

Re: Win7-10: Can scripts echo to a file in the root of the C drive?

You can install Windows to any drive letter you want; people just usually choose C: for historical reasons. I've seen the Windows drive be A: before.

If you want a guaranteed location that isn't %~dpn0, use a path that's referenced by a system variable, like %TEMP%.

Offline

#3 26 Jan 2020 00:32

Rekrul
Member
Registered: 17 Apr 2016
Posts: 71

Re: Win7-10: Can scripts echo to a file in the root of the C drive?

Shadow Thief wrote:

You can install Windows to any drive letter you want; people just usually choose C: for historical reasons. I've seen the Windows drive be A: before.

I've never seen that myself. I know that all the companies like Dell use C: and pretty much all the people I know wouldn't even know how to install Windows, let alone install it to anything other than C:.

Shadow Thief wrote:

If you want a guaranteed location that isn't %~dpn0, use a path that's referenced by a system variable, like %TEMP%.

I always think of Temp directories as being risky places to store anything for any length of time. Don't they get cleaned out periodically by Windows? Or other software that attempts to delete unnecessary files?

Offline

#4 27 Jan 2020 12:36

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,108

Re: Win7-10: Can scripts echo to a file in the root of the C drive?

Don't they get cleaned out periodically by Windows?

Not in my experience, but it is a location that the savvy (or at least Google savvy) might wind up messing about in if they are trying to free up disk space.

On WinXP there are far fewer controls about where you can write, so you may be able get away with C:\ (subject to user level).  If the config doesn't need to be system-wide, putting it in %USERPROFILE% or %APPDATA% would seem like better bets.


cmd | *sh | Ruby | Chef

Offline

#5 28 Jan 2020 21:05

Rekrul
Member
Registered: 17 Apr 2016
Posts: 71

Re: Win7-10: Can scripts echo to a file in the root of the C drive?

bluesxman wrote:

Not in my experience, but it is a location that the savvy (or at least Google savvy) might wind up messing about in if they are trying to free up disk space.

On WinXP there are far fewer controls about where you can write, so you may be able get away with C:\ (subject to user level).  If the config doesn't need to be system-wide, putting it in %USERPROFILE% or %APPDATA% would seem like better bets.

It doesn't need to be system wide. Actually, it's nothing super-important as it's only a few parameters that can easily be changed, I just thought that it would be nice if people had the option of saving them so they didn't have to be changed each time. One option I'm thinking of adding is letting people enter a destination directory for files and since they'd have to type it in, it would be nice if it (optionally) stayed set from one session to the next.

I just wasn't sure where would be a safe or allowed place to save it to since newer versions of Windows are much stricter about where programs can write to. I've heard that Windows doesn't even like programs to write their settings to an INI file in the program's install directory.

Offline

Board footer

Powered by FluxBB