Windows 10: Batch file that runs once for all new user accounts

Discus and support Batch file that runs once for all new user accounts in Windows 10 Software and Apps to solve the problem; Hey guys i need some help. I have an app called StartIsBack that i installed on our school computers. I want to do 2 things. First i want to add a... Discussion in 'Windows 10 Software and Apps' started by afdude08, Aug 12, 2017.

  1. afdude08 Win User

    Batch file that runs once for all new user accounts


    Hey guys i need some help. I have an app called StartIsBack that i installed on our school computers. I want to do 2 things. First i want to add a registry key to the hkey current user key that copies the customized start menu settings when the user first logs on silently and then restarts windows explorer. I want to set the batch file to delete after the key is installed. Any help on this would be greatly appreciated. I couldnt get sysprep copyprofile to work with my image so i am trying to find a different method of doing this. Thanks so much!

    :)
     
    afdude08, Aug 12, 2017
    #1
  2. amikhan1 Win User

    How to add a prompt dialog box through a batch file

    Hi All,

    Hope you all are doing good, I have a simple question where in i am trying to run two batch scripts and i want to add a prompt dialog box after the completion of one script so that once the user hits Yes the second batch file should not run if clicked on
    no it should execute the batch file

    Your suggestion would be of great help.

    Thanks
     
    amikhan1, Aug 12, 2017
    #2
  3. Simon_T Win User
    Task Scheduler jobs not working after Anniversary Update

    Hi All,

    I have the same problem running a batch file to allow the showing of all users. This is for local users without a password. I run a batch file as a scheduled task with "run whether user is logged on or not" and it stopped working since the anniversary update.
    I've deleted the task and re-added it but it will not run.

    The batch file still works if I double click it.

    Has this bug been reported to Microsoft?

    Simon
     
    Simon_T, Aug 12, 2017
    #3
  4. Try3 Win User

    Batch file that runs once for all new user accounts

    1 You can use the Reg command to do the Registry work - you can find out how to use it by entering reg /? in a command window.
    2 You can restart Windows explorer using the guidance in Option 2 of How to Restart explorer.exe Process in Windows 10
    3 You can get the batch file to delete itself by putting a del command on the last line of the batch file.
     
  5. Kari Win User
    What was the issue with Sysprep? Maybe we could help you finding a solution for that.

    I'm asking because the easiest and recommend way to do this is to do it in Audit Mode, Sysprep with CopyProfile set to TRUE. Open Notepad, type your commands and add del %0 as last command line. That takes care of deleting the batch when it's run. Save the file as a .bat in %appdata%\Microsoft\Windows\Start Menu\Programs\Startup.

    I usually name these batches I want to be run only once whenever a new user signs in first time as RunOnce.bat.

    When done, run Sysprep. Remember that for CopyProfile to work you must use the /generalize switch with Sysprep command, for instance to run Sysprep and shutdown to be able to capture the Windows image, you would use the following command:

    %windir%\system32\sysprep\sysprep.exe /generalize /oobe /unattend:W:\YourAnswerFile.xml

    /unattend:AnswerFilePathAndName.xml is optional; if you save the answer file as unattend.xml in C:\Windows\System32\Sysprep folder, it will be automatically used. If you name the answer file to something else, or save it to another location, use /unattend switch.

    That's it.

    I'll add a sample RunOnce.bat below, you can just copy and modify it according to your needs. This sample batch would set screensaver active (enabled) setting the value of string (REG_SZ) ScreenSaveActive to 1, and force user to enter password when resumed from screensaver by setting the value of string ScreenSaverIsSecure to 1. Both strings are in key HKEY_CURRENT_USER\Control Panel\Desktop. When new user signs in first time, the batch will be run and deleted so it only runs once for each new user:

    Code: reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaveActive /d "1" /t REG_SZ /f reg add "HKEY_CURRENT_USER\Control Panel\Desktop" /v ScreenSaverIsSecure /d "1" /t REG_SZ /f del %0[/quote] (Please notice, there are no typos in above batch sample. First string uses label ScreenSave, the second ScreenSaver.)

    Syntax of reg add command:

    reg add "Key Name" /v ValueName /d "Value" /t DataType /f

    Valid data types:
    - REG_SZ = String value
    - REG_MULTI_SZ = Multi-string value
    - REG_EXPAND_SZ = Expandable string value
    - REG_DWORD = DWORD 32 bit value
    - REG_QWORD = QWORD 64 bit value
    - REG_BINARY = Binary value
    The /f switch forces writing the new value without prompting the user.

    Last but not least, if you want this batch to be run only once when first initial user signs in to Windows, but not later when additional users sign in, save the batch in %programdata%\Microsoft\Windows\Start Menu\Programs\Startup instead of %appdata%.


    DEL alone is not enough. Name of current batch process is stored in variable %0, the last line of batch should therefore be del %0.
     
  6. afdude08 Win User
    When I used the answer file that I had on my external storage device when i sysprepped, everything seemed to go fine when the computer shut down but when the computer restarted we had an issue where it was just stuck at the customizing your keyboards and default timezone screen and after you clicked on next, it just was stuck on "just a moment" for hours. Kari, your tutorials on sysprepped machines states (from my understanding) that in order to make an unattended answer file in windows SIM, you have to have the windows ISO image of the computer you're working on. However this is not the case as I do not have the exact image that is on these computers from Dell. I was just trying to use the image that was already on the machine to make my changes and then sysprep that machine to all the rest of the computers. Thanks
     
    afdude08, Aug 12, 2017
    #6
  7. Kari Win User
    No, you can of course use any install.wim file to create catalog file in Windows SIM, as long as it is for the same Windows version. If you are creating an answer file on your technician machine for 64 bit Windows 10 version 1703, you need either a catalog file for that or if you don't have one, a 64 bit install.wim file from W10 version 1703 install media, be it ISO or USB.
     
  8. afdude08 Win User

    Batch file that runs once for all new user accounts

    Ohhhhh!!! That might be the fix!! I was using a 1703 iso image when i made my answer file but the computers are 1607 xD im a dunce lol. Thanks Kari i will try that monday and ill check back in here *Smile
     
    afdude08, Aug 12, 2017
    #8
  9. Kari Win User
    I don't believe that is your issue, 1607 is close enough. What I posted is "the rule", official recommendation, but I have for instance successfully used 1607 catalog files for 1703 and vice versa. It's just that a new version can bring in a new answer file component that the old version does not recognize, or an answer file made with older catalog file might included components deprecated in later versions.

    If you replace all sensitive information like product keys, user and organization names in answer file with bunch of X's and Y's and post it here, we could take a look to see if there's something obvious that is causing your issues.
     
  10. afdude08 Win User
    But see that's the thing the only thing that I use in my answer file was copyprofile I didn't have any other things set in my answer file that was the only thing that I had set. But ill post it monday
     
    afdude08, Aug 12, 2017
    #10
  11. afdude08 Win User
    And i wished answer files were backwards compatible but i understand if deprecated component being an issue here
     
    afdude08, Apr 5, 2018
    #11
Thema:

Batch file that runs once for all new user accounts

Loading...
  1. Batch file that runs once for all new user accounts - Similar Threads - Batch file runs

  2. Cant run Batch file

    in Windows 10 Gaming
    Cant run Batch file: When i try to run a batch file all it says is this app can't run on your pc i tried going to my property and going to compatibility but it isn't there im on windows 11 btw but if someone can pls help...
  3. Cant run Batch file

    in Windows 10 Software and Apps
    Cant run Batch file: When i try to run a batch file all it says is this app can't run on your pc i tried going to my property and going to compatibility but it isn't there im on windows 11 btw but if someone can pls help...
  4. Batch File run but GUI not prompt

    in Windows 10 Gaming
    Batch File run but GUI not prompt: Hello,I made an batch file to run exe file but GUI prompt not appear if i tried to run from outside i.e. batch file present on ABC Folder and I am going to command prompt and run the same it's running and GUI Interface shows but when I runneed the file from other directory...
  5. Batch File run but GUI not prompt

    in Windows 10 Software and Apps
    Batch File run but GUI not prompt: Hello,I made an batch file to run exe file but GUI prompt not appear if i tried to run from outside i.e. batch file present on ABC Folder and I am going to command prompt and run the same it's running and GUI Interface shows but when I runneed the file from other directory...
  6. run batch file step by step

    in Windows 10 Customization
    run batch file step by step: Hi to all I need your help and support, I'm a Test Engineer and I dedicate and maintain to develop and improve batch files, and I need to know if somebody knows, how to run a batch file step by step in windows 10 or windows server?. Previously in ms-dos i use the next line...
  7. How to run a batch file in admin mode from a user account?

    in Windows 10 Support
    How to run a batch file in admin mode from a user account?: I've created batch files to run the following commands to work around a particular problem: sc stop cldflt sc start cldflt The batch files work in my user account if you right click and run them as Administrator. There are methods on the forum to run these batch files from...
  8. Running PowerShell script as a batch file

    in Windows 10 Network and Sharing
    Running PowerShell script as a batch file: Can I run the Power Shell line: "C:\Windows\System32>get-appxpackage *3dbuilder* | remove-appxpackage" from a .Bat file? ***Original title: Removing bloatware***...
  9. Run oscdimg.exe from a batch file?

    in Windows 10 Installation and Upgrade
    Run oscdimg.exe from a batch file?: OK, I have a batch file that copies files from a mounted windows 10 installation file and updates drivers in boot.wim and install.wim. The thing I cannot work out is how to automatically run oscdimg.exe (command from deployment and imaging environment) in a batch file so I...
  10. Running an uneditable Batch file

    in AntiVirus, Firewalls and System Security
    Running an uneditable Batch file: Hi people, Got a task to run a certain CMD command on a number of PCs as administrator. So I thought i would create a batch file doing this. This is not the issue. The issue is that I am unable to lock down successfully so people cannot just edit the file to see the admin...