Adapting .REG Files.

Page 11 of 13 FirstFirst ... 910111213 LastLast
  1. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #101

    Extract the files and just double-click on "# Run batch files.cmd" without changing anything. Tell me the results.
    Adapting .REG Files. Attached Files
      My Computer

  2. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #102

    Thanks @Matthew Wai,
    Matthew Wai said:
    Extract the files and just double-click on "# Run batch files.cmd" without changing anything. Tell me the results.
    It worked!

    It stopped with the file that could not be processed, I clicked OK and it continued, and it also gave me the Operations completed and Pause at the end.

    So is the reason the other .cmd scripts didn't run have something to do with the fact it was being run from a different directory instead of within the same directory?

    I replaced %~dp0*.bat with C:\Users\System-Admin\System_Admin_Implementation\*.bat and it didn't work!

    It doesn't matter, the point is it works, thank you.
    Last edited by Paul Black; 19 Mar 2020 at 06:32.
      My Computer

  3. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #103

    Paul Black said:
    C:\Users\System-Admin\System_Admin_Implementation\*.bat
    Keep using the above path in "# Run batch files.cmd".
    Move all .bat files in \System_Admin_Implementation\ to another folder.
    Copy all .bat files in \Paul Black\ into \System_Admin_Implementation\.
    Double-click on "# Run batch files.cmd" in \Paul Black\ .
    Tell me the results.
      My Computer

  4. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #104

    Thanks @Matthew Wai,

    Matthew Wai said:
    Keep using the above path in "# Run batch files.cmd".
    Move all .bat files in \System_Admin_Implementation\ to another folder.
    Copy all .bat files in \Paul Black\ into \System_Admin_Implementation\.
    Double-click on "# Run batch files.cmd" in \Paul Black\ .
    Tell me the results.

    I did as you advised above and it Worked!

    I then copied the .bat files I want to use into the folder three at a time and run the code again. I found one file which I have listed below that made the code exit as before. I copied the rest of the files into the folder [except that one] and ran the code again and it Worked. So there was a problem .bat file that stopped the previous versions running. The file in question is . . .

    Code:
    :: Created by: Shawn Brink
    :: Created on: October 13th 2017
    :: Tutorial: https://www.tenforums.com/tutorials/95383-enable-disable-fast-user-switching-windows-10-a.html
    
    powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/s,/c,REG Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & REG Delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & taskkill /f /im explorer.exe & start explorer.exe' -Verb runAs"

    It is NOT a problem because when I come to run this on my actual OS I will leave that one out and run it separately. Thanks to the code it was easy to find.

    As your code needs to be run from within the active directory, I then changed the code so that it could be run from outside the active directory and that Worked also . . .

    Code:
    @echo off
    Set Folder="C:\Users\System-Admin\System-Admin_Implement"
    cd %Folder%
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    For %%i In ("%Folder%\*.bat") Do (echo Processing: "%%i"&CMD /C "%%i" & echo.)
    echo Operations completed. & pause

    I have got to go out for a while but I will try creating a new code to run .ps1 PowerShell files and then I can finally mark this thread as solved!
      My Computer

  5. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #105

    The following is my suggestion. Give it a go.
    Code:
    @echo off
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    Set "Folder=C:\Users\System-Admin\System-Admin_Implement"
    For %%i In ("%Folder%\*.bat") Do (echo Processing "%%i"&CMD /C "%%i" & echo.)
    echo The last one is pending. & pause
    
    powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/s,/c,REG Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & REG Delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & taskkill /f /im explorer.exe & start explorer.exe' -Verb runAs"
      My Computer

  6. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #106

    Thanks @Matthew Wai,

    Matthew Wai said:
    The following is my suggestion. Give it a go.
    Code:
    @echo off
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    Set "Folder=C:\Users\System-Admin\System-Admin_Implement"
    For %%i In ("%Folder%\*.bat") Do (echo Processing "%%i"&CMD /C "%%i" & echo.)
    echo The last one is pending. & pause
    
    powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/s,/c,REG Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & REG Delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & taskkill /f /im explorer.exe & start explorer.exe' -Verb runAs"
    That will NOT work because the file will need to be in the same folder, which as we know, causes the script to exit straight away.

    As I said previously, it is NOT a problem to just to run that single script manually.
    I like your thinking though.
    Last edited by Paul Black; 19 Mar 2020 at 13:17.
      My Computer

  7. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #107

    Paul Black said:
    That will NOT work because the file will need to be in the same folder, which as we know, causes the script to exit straight away.
    That will work because the file can be deleted from the same folder. The commands in the .bat file in question have been put at the end of the .cmd file used to run other .bat files.
      My Computer

  8. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #108

    Paul Black said:
    Code:
    :: Created by: Shawn Brink
    :: Created on: October 13th 2017
    :: Tutorial: https://www.tenforums.com/tutorials/95383-enable-disable-fast-user-switching-windows-10-a.html
    
    powershell -windowstyle hidden -command "Start-Process cmd -ArgumentList '/s,/c,REG Delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & REG Delete HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /V HideFastUserSwitching /F & taskkill /f /im explorer.exe & start explorer.exe' -Verb runAs"
    I suggest removing the following part, which can be run manually after all batch files have been run automatically.

    taskkill /f /im explorer.exe & start explorer.exe

    The above part could have forced your CMD window to exit automatically.
      My Computer

  9. Paul Black's Avatar
    Posts : 12,191
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
    Thread Starter
       #109

    Thanks @Matthew Wai,

    Matthew Wai said:
    I suggest removing the following part, which can be run manually after all batch files have been run automatically.

    taskkill /f /im explorer.exe & start explorer.exe

    The above part could have forced your CMD window to exit automatically.
    That works Perfectly thank you!
    Yes, you are right, the above snippet was the cause of forcing the CMD window to exit automatically.
    Thanks very much again!

    I will have a go at running all the .ps1 files now and then I can mark this thread as solved!
      My Computer

  10. Matthew Wai's Avatar
    Posts : 5,072
    Windows 10 Home 20H2
       #110

    Yet another suggestion:
    Code:
    @echo off
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    Set "Folder=C:\Users\System-Admin\System-Admin_Implement"
    For %%i In ("%Folder%\*.bat") Do (echo Processing "%%i"&CMD /C "%%i" & echo.)
    echo Press a key to restart "explorer.exe". & pause > nul
    taskkill /f /im explorer.exe & start explorer.exe
    "explorer.exe" will be restarted only after you press a key after all the .bat files have been processed.
      My Computer


 
Page 11 of 13 FirstFirst ... 910111213 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 18:37.
Find Us




Windows 10 Forums