Just trying to include a script in a shared dropbox folder. The filepath includes the username, and that is different per machine, so it might be:
Include>C:\Users\Administrator\Dropbox\myScript.scp
but if the username is different than "Administrator", the filepath doesn't work.
Windows filepath info I found online says to use double dot delimiter, but the following does not work.
Include>C:\Users\..\Dropbox\myScript.scp
It's not a subdirectory of the executing script's directory, so I'm not seeing some other way of using relative filepaths. Does MS use some other method of non-explicit filepaths that allows me to do the equivalent of /../
Non-explicit filepaths
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Non-explicit filepaths
Use the DESKTOP_DIR variable:
MessageModal>DESKTOP_DIR
MessageModal>DESKTOP_DIR
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Non-explicit filepaths
Sorry, I realized my generic example referred to the desktop, and that something specific to desktop like DESKTOP_DIR might exist, so I edited question to be specific to what I'm actually looking at which doesn't reference desktop. I had assumed at first that since my Dropbox folder is on the desktop that the filepath of files within would reflect that, but they don't. I guess that's a shortcut, because actual filepath is:
Include>C:\Users\Administrator\Dropbox\myScript.scp
A couple other ways to avoid explicit username that I found online, but that did not work:
Include>~\Dropbox\myScript.scp
Include>C:\Users\%USERPROFILE%\Dropbox\myScript.scp
Include>C:\Users\Administrator\Dropbox\myScript.scp
A couple other ways to avoid explicit username that I found online, but that did not work:
Include>~\Dropbox\myScript.scp
Include>C:\Users\%USERPROFILE%\Dropbox\myScript.scp
- Marcus Tettmar
- Site Admin
- Posts: 7380
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Non-explicit filepaths
Try:
However, I don't know if you can assume that Dropbox is always in the profile. Maybe. Maybe not. At some point you might just have to store system specific settings in the registry or an INI file.
Consider using an INI file which you store in the same folder as the script and then refer to it with:
Your INI file would look like:
Code: Select all
GetEnvVar>USERPROFILE,profilePath
Let>dropboxPath=%profilePath%\Dropbox
Consider using an INI file which you store in the same folder as the script and then refer to it with:
Code: Select all
ReadIniFile>%SCRIPT_DIR%\mysettings.ini,SETTINGS,DropBoxDir,dropboxPath
Code: Select all
[SETTINGS]
DropBoxDir=c:\bla\bla\dropbox
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Non-explicit filepaths
Setup is always the same, but most are Windows 2012, and a few are other Windows builds from other providers where the default may be "Admin" rather than "Administrator" or some such variation.
Looks like GetEnvVar>USERPROFILE,profilePath was exactly what I needed.
Thx.
Looks like GetEnvVar>USERPROFILE,profilePath was exactly what I needed.
Thx.