running DOS as ADMIN

Page 4 of 11 FirstFirst ... 23456 ... LastLast

  1. Posts : 245
    windows 10
    Thread Starter
       #31

    bromberg said:
    Denis,
    Thanks for your thoughts.
    Dan
    Steps 1 to 3 went fine but I'm having a problem with your step 4 since I do not see Authenticated users, Read & execute - Apply
    So can you can be more specific where these options are in the ADVANCED SECURITY SETTINGS PANEL?
    Thanks,
    Dan
      My Computer


  2. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #32

    Dan,

    I copied that procedure straight out of my own setting up records and I can now see that there is a missing step - clicking on Change permissions.

    I have changed the procedure to

    1 Create folder C:\Tools
    2 Properties, Security, Advanced
    3 Disable inheritance, Confirm convert them into explicit permissions
    4 Change permissions, then for each of Authenticated users & Users
    select the list entry for <Authenticated users / Users>,
    Edit,
    set the check boxes for Read & execute, List folder contents and Read
    OK,
    Apply
    5 Set Owner to Administrators {being careful to use the plural because using the singuar would have a specific meaning that would trip you up}
    6 Replace owner on subcontainers & objects

    If all you have is a Users entry then set that up and you are done. But mine has always listed Authenticiated users as well as Users.




    But I think this is putting the cart before the horse. You can set up C:\Tools as a location for your own batch files etc after you have sorted out the current problem.

    What are your answers to my questions about
    1 whether or not the Admin prompt appears and looks like it is behaving itself, and
    2 running the batch file by setting a log file output in its shortcut [>D:\Desktop\MyBatchFile.log]

    Denis
      My Computer


  3. Posts : 245
    windows 10
    Thread Starter
       #33

    Try3 said:
    Dan,

    I copied that procedure straight out of my own setting up records and I can now see that there is a missing step - clicking on Change permissions.

    I have changed the procedure to

    1 Create folder C:\Tools
    2 Properties, Security, Advanced
    3 Disable inheritance, Confirm convert them into explicit permissions
    4 Change permissions, then for each of Authenticated users & Users
    select the list entry for <Authenticated users / Users>,
    Edit,
    set the check boxes for Read & execute, List folder contents and Read
    OK,
    Apply
    5 Set Owner to Administrators {being careful to use the plural because using the singuar would have a specific meaning that would trip you up}
    6 Replace owner on subcontainers & objects

    If all you have is a Users entry then set that up and you are done. But mine has always listed Authenticiated users as well as Users.




    But I think this is putting the cart before the horse. You can set up C:\Tools as a location for your own batch files etc after you have sorted out the current problem.

    What are your answers to my questions about
    1 whether or not the Admin prompt appears and looks like it is behaving itself, and
    2 running the batch file by setting a log file output in its shortcut [>D:\Desktop\MyBatchFile.log]

    Denis
    This runs fine from an ADMIN DOS window:
    Code:
    "C:\Users\danny\Desktop\danny.BAT" > "C:\Users\danny\Desktop\danny.LOG"
    as shown by the LOG file that gets created (thanks for this good idea) as well as the expected output I was hoping for.

    However, when I run this same 'bat' file by right-clicking run-as-admin then the DOS window flashes momentarily and the output I had hoped for does not change, which is obviously telling me the command did not execute (probably because it lost (or never had) the required authorization).

    Is there a DOS command I could execute within my bat-file to query if I am running as an ADMIN (or better yet, to request ADMIN status)?
    Thanks,
    Dan
      My Computer


  4. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #34

    What are your answers to my questions about
    1 whether or not the Admin prompt appears and looks like it is behaving itself, and
    I was trying to eliminate this as an issue to check through. It will be covered by my step B below.


    Change the batch file's shortcut to include the log file output and then run it from the shortcut.

    Your shortcut already has the run as Admin property set from what you have posted previously - if not then
    1 Right-click on the shortcut
    2 [check you have added the output to its Target field]
    3 Click on Advanced
    4 Set the checkbox for Run as Admin
    5 OK, OK
    running DOS as ADMIN-shortcut-runasadmin.png

    Then you'll just be able to
    A double-click on the shortcut,
    B give Admin approval,
    C watch the Command window flicker then
    D read the output file in Notepad.
    - Remember to remove all the Pause lines from the batch file first or you'll just see the batch file's Command window hanging there.

    There are more complicated ways of setting up a batch file to run as Admin [some of which have been discussed in this thread already] but, since you are just doing this as a temporary method of fault diagnosis, I do not see the point in doing any more work than is necessary.

    Denis
      My Computer


  5. Posts : 582
    Windows 10 Home
       #35

    If K: is a network drive, you may have to remap it when running as administrator. Replace "computername" with the actual computer name.

    schtasks /run /i /tn "\Microsoft\Windows\Registry\RegIdleBackup"
    cd c:\windows\system32\config\regback
    dir
    pause
    if not exist K:\nul net use K: \\computername
    copy C:\Users\dan\Desktop\dan-apps\danBM.xls K:\BU\THUMBDRIVE-BM.xls
    robocopy C:\Users\dan\Desktop\dan-app\ K:\BU\ METrack.xls
    pause
    %windir%\system32\shutdown.exe -s -t 0

    Ben
    Last edited by Ben Myers; 03 Aug 2019 at 16:17.
      My Computer


  6. Posts : 245
    windows 10
    Thread Starter
       #36

    Ben Myers said:
    If K: is a network drive, you may have to remap it when running as administrator. Replace "computername" with the actual computer name.

    schtasks /run /i /tn "\Microsoft\Windows\Registry\RegIdleBackup" cd c:\windows\system32\config\regbackdirpause
    if not exist K:\nul net use K: \\computername
    copy C:\Users\dan\Desktop\dan-apps\danBM.xls K:\BU\THUMBDRIVE-BM.xlsrobocopy C:\Users\dan\Desktop\dan-app\ K:\BU\ METrack.xlspause %windir%\system32\shutdown.exe -s -t 0

    Ben
    Ben:
    K is just a thumb drive (not a network drive) that I use for a backup of a few files each time I shutdown.
    But thanks,
    Dan
      My Computer


  7. Posts : 582
    Windows 10 Home
       #37

    Try adding "cd %~dp0" after the "dir" command. This changes the working directory to the folder in which the batch resides.

    schtasks /run /i /tn "\Microsoft\Windows\Registry\RegIdleBackup"
    cd c:\windows\system32\config\regback
    dir
    cd %~dp0
    pause
    copy C:\Users\dan\Desktop\dan-apps\danBM.xls K:\BU\THUMBDRIVE-BM.xls
    robocopy C:\Users\dan\Desktop\dan-app\ K:\BU\ METrack.xls
    pause
    %windir%\system32\shutdown.exe -s -t 0

    Ben
      My Computer


  8. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #38

    There is no point in making random changes to a batch file when you could be spending your time diagnosing the problem instead.

    Job the shortcut as I have suggested and you will find out what the problem is.
    - Make sure you remove all pauses beforehand.

    Denis
      My Computer


  9. Posts : 245
    windows 10
    Thread Starter
       #39

    Ben Myers said:
    Try adding "cd %~dp0" after the "dir" command. This changes the working directory to the folder in which the batch resides.

    schtasks /run /i /tn "\Microsoft\Windows\Registry\RegIdleBackup"
    cd c:\windows\system32\config\regback
    dir
    cd %~dp0
    pause
    copy C:\Users\dan\Desktop\dan-apps\danBM.xls K:\BU\THUMBDRIVE-BM.xls
    robocopy C:\Users\dan\Desktop\dan-app\ K:\BU\ METrack.xls
    pause
    %windir%\system32\shutdown.exe -s -t 0

    Ben
    I think I'm misunderstanding you since when I issue the 'cd' command, this is what I get:
    c:\Windows\System32\config\RegBack>dir

    Directory of c:\Windows\System32\config\RegBack

    08/03/2019 01:12 PM <DIR> .
    08/03/2019 01:12 PM <DIR> ..
    08/03/2019 01:12 PM 983,040 DEFAULT
    08/03/2019 01:12 PM 69,632 SAM
    08/03/2019 01:11 PM 32,768 SECURITY
    08/03/2019 01:11 PM 109,477,888 SOFTWARE
    08/03/2019 01:12 PM 18,219,008 SYSTEM
    5 File(s) 128,782,336 bytes
    2 Dir(s) 363,965,292,544 bytes free

    c:\Windows\System32\config\RegBack>cd %~dp0
    The system cannot find the path specified.

    c:\Windows\System32\config\RegBack>
      My Computer


  10. Posts : 582
    Windows 10 Home
       #40

    It should work properly in the batch file. If you are not comfortable using an unfamiliar command, try eliminating the "cd" line. It may be causing a problem with the rest of the batch.

    schtasks /run /i /tn "\Microsoft\Windows\Registry\RegIdleBackup"
    dir c:\windows\system32\config\regback
    pause
    copy C:\Users\dan\Desktop\dan-apps\danBM.xls K:\BU\THUMBDRIVE-BM.xls
    robocopy C:\Users\dan\Desktop\dan-app\ K:\BU\ METrack.xls
    pause
    %windir%\system32\shutdown.exe -s -t 0

    Ben
      My Computer


 

  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 17:13.
Find Us




Windows 10 Forums