Is it feasble for users to run batch scripts that perform commands for download and run apps by default?

JohnCTX 636 Reputation points
2021-01-04T15:01:32.88+00:00

Another step in the process.

Is it possible for users to automatically run apps by default, and then automatically assign their User ID and Product ID along with them immediately after downloaded status?

Regards,

JohnCTX

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,422 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 47,966 Reputation points
    2021-01-05T20:44:23.467+00:00

    It sounds to me like you shouldn't store anything. When your app starts grab the current user's name or SID (your choice) and the Windows ID and use it. No reason to cache this anywhere as it could change.

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Michael Taylor 47,966 Reputation points
    2021-01-04T15:05:20.337+00:00

    Please be more specific in exactly what you're trying to do including whether you're trying to do this programmatically, from Powershell, etc. Also what you do you mean by user ID, product ID and download status? None of this makes sense to us.

    Yes a user can have apps run automatically at logon of Windows by any # of means: putting shortcut into their Startup group folder, adding registry entry under HKCU, using Task Scheduler to schedule tasks at logon. But all such apps will only run with the data that is provided to them so it is unclear what this has to do with a user ID, product ID and download status.


  2. Michael Taylor 47,966 Reputation points
    2021-01-05T15:24:37.83+00:00

    User ID? You mean their user name or their SID? User name is only guaranteed unique within the domain it is defined. SID should be unique as it is a GUID.

    Product ID of Windows is determined by the installation of the OS. There would be only 1 product ID for all users running on the same OS instance.

    I still don't understand how this applies to your original question. You don't assign a user an ID unless you're creating a new account. An admin would do this before the user could log in the first time. They would need a password at the same time. The Product ID of Windows is set when WIndows is installed. I'm also not sure what you're checking the download status of. A more detailed description of what you're trying to do would be helpful here.


  3. Michael Taylor 47,966 Reputation points
    2021-01-05T19:36:25.697+00:00

    1-2) So the downloaded app is your app that you built and you have an installer that installs it.
    3) If you want to capture the user's name and the product ID from Windows you should do that as part of the installer.

    The issue with the installer is that generally it is installed once for all users on the machine. Therefore the installer would run as admin and not the user who likely would run the app. Perhaps this is what you are referencing in 4 when you say the user will start the app (or the installer can do this instead but then it runs under the installer process credentials). In this case you could capture the user name and product ID. But you are now stuck with where to persist this. The registry is the appropriate location but the problem is that a regular user does not have write access to the registry where you'd want to store it.

    But multiple users may run the app. What happens then? Should all users on a machine use the same user/product ID? If so then you cannot use the username anymore (or SID). Instead the user ID would need to be provided by the app somehow. If each user gets their own user/product ID value then you'd store it in the user's registry. In this case you would have write access. Now if user A and user B both start the app on a machine they would each have their own user/product ID.

    But if you are just going to use the current user's name/ID and the Windows product ID then there is no reason to store it at all. You can retrieve this information on startup of the app. This makes it more resilient to change. A username can change over time but the SID is permanent. The WIndows product ID can actually change over time if a user upgrades their OS without reinstalling. Pulling the data at startup makes the most sense here.

    The only time I'd probably store this info is if the info is provided by you to the user (sort of like a registered user ID and serial #). In this case it probably makes sense to collect it at installation time and fail to install if not provided.