+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
Scripts Thread, Run .bat File as Administrator in Coding and Web Development; I've got a .bat file I want to run on startup, but it needs to run as administrator - anyone ...
  1. #1
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75

    Run .bat File as Administrator

    I've got a .bat file I want to run on startup, but it needs to run as administrator - anyone know a way of doing that, or could anyone re-write the command in vbs for me?

  2. #2

    Join Date
    Apr 2008
    Posts
    853
    Thank Post
    111
    Thanked 112 Times in 108 Posts
    Rep Power
    45
    should work in user startup in ggp?

  3. #3
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Needs to be machine startup, not user startup.

  4. #4


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,506
    Thank Post
    227
    Thanked 848 Times in 727 Posts
    Rep Power
    287
    Quote Originally Posted by enjay View Post
    Needs to be machine startup, not user startup.
    computer startup scripts do run as admin as far as im aware

  5. #5

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,786
    Thank Post
    272
    Thanked 1,130 Times in 1,026 Posts
    Rep Power
    348
    Quote Originally Posted by sted View Post
    computer startup scripts do run as admin as far as im aware
    Yup the do - if its not working there is something wrong with the script! Can you call it from a command prompt and it do want you want as admin?

  6. #6
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Quote Originally Posted by glennda View Post
    Yup the do - if its not working there is something wrong with the script! Can you call it from a command prompt and it do want you want as admin?
    Yes, the batch file runs fine from a command prompt as administrator, but not as my regular domain admin logon.

    Basically, I'm trying to delete the cached user profiles - these should be getting deleted at logoff by Group Policy, but on this one computer they're not, and this is causing profile corruption problems. I thought scripting them to delete at startup would be a good stop-gap whilst I fix the GPO issue.

  7. #7

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,786
    Thank Post
    272
    Thanked 1,130 Times in 1,026 Posts
    Rep Power
    348
    What OS is the machine? xp?

  8. #8
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Quote Originally Posted by glennda View Post
    What OS is the machine? xp?
    Win 7 Pro.

  9. #9
    jsnetman's Avatar
    Join Date
    Oct 2007
    Posts
    887
    Thank Post
    23
    Thanked 134 Times in 126 Posts
    Rep Power
    39
    User startup scripts run with the the same rights as the user logging on. You will be able to use the script in the machine startup policy as that will run with system rights. However if this is XP we are talking about you could insall the "User Hive Cleanup" utility from MS and also use delprof.exe in a machine startup script.

  10. #10

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,786
    Thank Post
    272
    Thanked 1,130 Times in 1,026 Posts
    Rep Power
    348
    Quote Originally Posted by enjay View Post
    Win 7 Pro.
    Try looking in registry hklm/software/microsoft/windows nt/current version/profilelist you may find windows 7 has the profile backed up you would see a uuid.bak if it is - if there is one just delete it.

    There is an ms kb about this somewhere. it always causes users to login with temp profile.

  11. #11
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Thanks Glennda. I remember that, now you say about it. This isn't the temp profile issue, but I'll give that a try anyway...

  12. #12

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,786
    Thank Post
    272
    Thanked 1,130 Times in 1,026 Posts
    Rep Power
    348
    Quote Originally Posted by enjay View Post
    Thanks Glennda. I remember that, now you say about it. This isn't the temp profile issue, but I'll give that a try anyway...
    Windows 7 should clear profiles anyway, so if it isn't there is something else wrong, if its only happening on one machine i would just image/rebuild it!

  13. #13

    3s-gtech's Avatar
    Join Date
    Mar 2009
    Location
    Wales
    Posts
    2,698
    Thank Post
    143
    Thanked 542 Times in 486 Posts
    Rep Power
    148
    Windows 7 isn't like XP where you can just clear profiles by deleting the folder from \Users (or Documents and Settings). I tried that when first testing profiles, and it caused major issues. You need to remove them from System Settings/Advanced/User Profiles (which also deletes the registry entries). Not sure how this can be done by script though.

    TBH, I've found Windows 7 looks after this quite well anyway, though we still get profiles sticking when the reg key isn't unloaded at logoff. Doesn't stop logons though.

  14. #14
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    I agree that Windows 7 should be sorting this itself, however in this instance it isn't. I have found that deleting the user's profile at C:\Users\[username] clears the problem, so want to set that up as a stop-gap whilst I address what is actually wrong with it. I've already re-imaged it without success, I may try it in a different OU to see if that does anything.

  15. #15
    enjay's Avatar
    Join Date
    Apr 2007
    Location
    Reading, Berkshire, UK
    Posts
    4,485
    Thank Post
    282
    Thanked 196 Times in 167 Posts
    Rep Power
    75
    Quote Originally Posted by glennda View Post
    Try looking in registry hklm/software/microsoft/windows nt/current version/profilelist
    No, her profile isn't listed in the registry.

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 9th October 2011, 08:12 PM
  2. Running a script as administrator
    By mrbios in forum Scripts
    Replies: 5
    Last Post: 23rd September 2010, 02:20 PM
  3. Tizzy's First Tools - Only Runs As Administrator
    By SYSMAN_MK in forum Educational Software
    Replies: 2
    Last Post: 7th November 2008, 11:49 PM
  4. Kids saving notepad files as command.bat
    By Kyle in forum Windows
    Replies: 15
    Last Post: 29th November 2006, 01:27 PM
  5. Run Script as Administrator
    By TSCNUK in forum Windows
    Replies: 8
    Last Post: 20th November 2006, 04:20 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •