Setting up users account with command-line

Hi

Here is my system, all newly setup as it’s a lab environment and I am testing

NC Server: VMWare Virtual Machine (hanssonit)
NC version: 31.0.7
Client OS: Windows 11
Desktop Client: 3.16.6-x64
Environment: Windows domain with AD

I have installed the NC client MSI on a windows 11 PC, but have not added any user accounts because I am trying to automate the adding user accounts process. Basically, if I run NC I get the Add NC account screen, which is what I want:

Currently I am working in a test environment, but I’m wanting to deploy where we will have up to 10 users with access to 6 PCs, within a windows active directory domain. Any user will be able to log into any PC and I don’t want the users to setup their NC account every time they log into a PC for the first time. I do not also want to setup each user manually on each PC, meaning I will have to log onto each PC, for each user and repeat the add NC account 60 times. Also, in the future if there’s a new user or new PC, a lot of manual configuration will be required.

I have read on the the NC website user manual it is possible to setup accounts for “Mass Deployment And Account Creation” so that the scenario above can be avoided and automated. The documentation is here:

I followed the instructions to created the --apppassword for a test user and obtained an app password to allow setting up the account via the command-line.

I then run the following command to add a user account with only the required argument:

C:\PROGRA~1\NEXTCL~1\NEXTCL~2.EXE --userid %username% --apppassword <my_generated_app_password> --serverurl https://<my_domain.com>

Note: C:\PROGRA~1\NEXTCL~1\NEXTCL~2.EXE will go to
C:\Program Files\Nextcloud\nextcloud.exe

This will work by connecting to the user account on the NC server, but it does not set the default local sync folder for the NC Server to connect to:

I can create the local sync folder manually by clicking “Add Folder Sync Connection” and going through the wizard and everything works fine, however this defeated the purpose of “Mass Deployment” as you need to add the local sync folder manually and do additional steps in the wizard. I only did this command with the minimum arguments for testing just to make sure I can establish a connection between the NC windows client and NC server.

What I am trying to do is set the local sync folder via the command-line as per the documentation, which requires adding the --localdirpath argument to the command above:

C:\PROGRA~1\NEXTCL~1\NEXTCL~2.EXE --userid %username% --apppassword <my_generated_app_password> --localdirpath C:\Test\ --serverurl https://<my_domain.com>

But then nothing happens, the command just fails and NC is still asking for a user account to connect to, ie no user account is added when the --localdirpath arguement is included:

I have tried various formats for the --localdirpath argument:

--localdirpath "C:\Test\"

--localdirpath 'C:\Test\'

I have also tried adding the --remotedirpath /Documents argument to the command and point to a folder named “Documents” on the NC server, but it still fails as above, ie no account is setup. I have tried the commands in both terminal and powershell but still the same outcome, ie with the minimum arguments the account is added but no local sync folder, with the --localdirpath argument, command fails and no account is added.

What I need is if someone can tell me how to get the --localdirpath argument to work with the command-line of nextcloud.exe or point to the documentation where I can see how this works.

Also, if someone can tell me how to change these settings via the command-line, that would also be appriciated:

Thanks in advance for any help

Kal …

1 Like

I do not really know Nextcloud on Windows with XAMPP. But i think you must use the php occ user:add command. Search the internet for more details.

user:add [--password-from-env] [--generate-password] [--display-name[="..."]] [-g|--group[="..."]] [--email EMAIL]
uid

Using the occ command — Nextcloud latest Administration Manual latest documentation

Hi @devnull, the setup is OK, I can add the account, but the issue is adding the local folder to syn.

Hi

Just a quick update, I got it working a little bit more, it was the security permissions set on C:\Test

So now if I use C:\Test as the local sync folder with the command:

C:\PROGRA~1\NEXTCL~1\NEXTCL~2.EXE --userid %username% --apppassword <my_generated_app_password> --localdirpath C:\Test\ --serverurl https://<my_domain.com>

Everything works as it should and the local syn folder is setup properly.

However, I would like to use a nextwork share mapped to drive R:\ with the command:

C:\PROGRA~1\NEXTCL~1\NEXTCL~2.EXE --userid %username% --apppassword <my_generated_app_password> --localdirpath R:\ --serverurl https://<my_domain.com>

But this fails like before with no account setup.

Any help would be much appriciated

Kal

  • I don’t have the reference handy but I remember there was some limit so you can’t use a root of the drive as sync target..
  • on the other side I would not recommend using remote drive for “local” sync. In windows vfs support is mature now so there is no drawback to (virtually) “sync” you whole NC data to the client without consuming local storage. and the experience is similar - frequently accessed files exist locally so you have full speed.. files not cached locally must be retrieved from NC server - but it works fast and transparent for the user.

thanks for your reply @wwe , I got it working, have to do a bit of manual setup with a script to setup the first NC account. Had to enable folder redirect so the AppData folder (where the NC configuration is kept) is on a network share, so if the same user logins into a different machine, it pulls the configuration from there and all the account settings, etc are loaded and NC client is working without any further configuration on the other machines.

Thanks for all your help

Kal …

1 Like

take care running such setup. In case users could simultaneously login to different machines (e.g. if they don’t logout from another session) you might hit issues like locked files etc.. I’m pretty sure the client is not designed to store files on a shared drive

@wwe , yeah I did think of that and you are right it will cause issues, luckily there are only 6 PCs and once a user logs ins they will use that PC for the rest of the shift and won’t be using any other PCs. It’s more when they are on shift again that they will be using a different PC.

@DJKalz possibly using session_lifetime and auto_logout will minimize file lock issues during shift changes:

Session lifetime, auto logout

the default session lifetime is 24 hours after which an idle user will be logged out automatically. Session lifetime and auto logout may be configured as required.

  • session_lifetime parameters are not user specific and apply to all users when configured
  • auto_logout is required and dependent on session_lifetime

TIP:
avoid session_lifetime below 4 hours in a corporate environment, as users will complain

TIP:

the documentation may be misleading, calculate the value for session_lifetime:

  • default value 24 hours (60x60x24) = 86400
  • value for 12 hours (60x60x12) = 43200
  • value for 8 hours (60x60x8) = 28800
  • value for 4 hours (60x60x4) = 14400