• Navigation
Results 1 to 14 of 14
  1. #1
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Getting around needing to run CMD as admin

    Is there any workaround for needing to run cmd as admin to execute a vbscript? I patched together a script that renames a machine and then reboots itself. I place the path to the vbs in the RunOnce section of regedit, and it works on booting up the machine BUT if I want to just rename the machine by going into CMD and pointing to the script, it wont rename it. Instead I have to go into the search, type CMD and then rightclick on it and select "run as administrator" even though the user I am signed on as is administrator.

    Reason I ask is I dont want to go to each new machine, make an admin account and then run the script, I just want it to go boom>boom>boom on all the machines with issue.

  2. #2
    Melee Summoner
    Join Date
    Jul 2008
    Posts
    46
    BG Level
    1
    FFXI Server
    Sylph

    There used to be a trick in Vista, here is a sample .reg file of how to do the workaround (don't think this works in 7 or 8, haven't tested)

    Windows Registry Editor Version 5.00

    [HKEY_USERS\S-1-5-21-2522326292-2955319634-115676670-1000\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
    "C:\\eclipse\\eclipse.exe"="RUNASADMIN"
    "C:\\Program Files\\Zune\\Zune.exe"="RUNASADMIN"
    "C:\\Program Files (x86)\\mIRC\\mirc.exe"="RUNASADMIN"
    "C:\\Program Files (x86)\\Bethesda Softworks\\Fallout 3\\Fallout3.exe"="VISTASP2 RUNASADMIN"
    "C:\\Program Files (x86)\\PlayOnline\\SquareEnix\\PlayOnlineViewer\\p ol.exe"="VISTASP2 RUNASADMIN"
    "C:\\Program Files (x86)\\Windower\\launcher.exe"="RUNASADMIN"
    "C:\\Program Files (x86)\\11N Wireless USB Adapter\\11N Wireless USB Adapter\\UI.exe"="RUNASADMIN"
    "C:\\Program Files (x86)\\Folding@home\\Folding@home-x86\\[email protected]"="RUNASADMIN"
    "C:\\Users\\Owner\\FFXI\\ApRadar\\ApRadar.exe"="RU NASADMIN"
    "C:\\Users\\Owner\\FFXI\\ApRadar\\ApUpdater.exe"=" RUNASADMIN"
    "C:\\Fraps\\fraps.exe"="RUNASADMIN"
    best of luck!

  3. #3
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Hmmm, ill try that out tomorrow. Something else I read seems to say we could create a shortcut to the script, set the shortcut to run as administrator and then point RunOnce to the shortcut instead of straight at the script.

  4. #4
    Nidhogg
    Join Date
    Feb 2008
    Posts
    3,790
    BG Level
    7
    FFXIV Character
    Tsugaru Mifra
    FFXIV Server
    Hyperion
    FFXI Server
    Ragnarok

    If you set the shortcut to run as administrator, which credentials are you going to provide? If an admin isn't logged into the box it's going to prompt for local or domain admin creds when you launch the shortcut.

  5. #5
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Quote Originally Posted by xopher View Post
    If you set the shortcut to run as administrator, which credentials are you going to provide? If an admin isn't logged into the box it's going to prompt for local or domain admin creds when you launch the shortcut.
    The script will run w/o credentials, the only issue is that if you just run CMD it runs unelevated so the script will rename the computer but error out because it doesnt have the right permissions to actually rename the machine and have it stick. I did modify the script to work through a shortcut, run the rename script and then delete the shortcut before rebooting. Seems to be working now but have to see if it works after cloning it.


    Also is anyone good with VMware here? I have a problem with cloning the master machine. Master machine has 3 accounts, 1 Administrator named Administrator, 1 basic user and then another set up as Administrator but with a name. After using a clone script, the new machine only has the named Admin user and basic user, and doesnt carry over the Administrator/Administrator. Renaming it doesnt make it clone over, and you can't delete the top lvl Administrator account either because Windows..

  6. #6
    Nidhogg
    Join Date
    Feb 2008
    Posts
    3,790
    BG Level
    7
    FFXIV Character
    Tsugaru Mifra
    FFXIV Server
    Hyperion
    FFXI Server
    Ragnarok

    I am VMWare certified.

    I've never seen that before. Typically a cloned VM is a bit for bit clone. I actually cloned the master image for our VMWare View environment today and all the admin accounts were left in tact. That's very strange. I wish I had a way of looking at your setup.

  7. #7
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Yeah i'm not sure. I havnt dabbled much at all in VB, but I know we have a script that takes data from a simple notepad file in the form of (StudentID)(Lastname)(FirstName) and uses that to name the cloned machines. There is an error return when we run the script but i'm at home so I cant remember what exactly it was but it had to do with something "-privilege" and not being able to use the value for the variable, wondering if that's what is causing the admin to not go through. It would be easier just to clone them by hand right now, but I love troubleshooting so trying to figure out what the kink is and fix it.

    Gonna build a few VMs tonight/tomorrow and monkey around at home and see if I can make it work.

    What do you guys do for cloning a master machine into 30 or so other machines with custom names?

  8. #8
    I Am, Who I Am.
    Join Date
    Nov 2005
    Posts
    15,656
    BG Level
    9
    FFXIV Character
    Trixi Sephyuyx
    FFXIV Server
    Excalibur
    FFXI Server
    Ragnarok

    Right click > Clone > Customize.

  9. #9
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Quote Originally Posted by SephYuyX View Post
    Right click > Clone > Customize.
    Bah, need an automated process. While that works, with how many ever students per class we need to clone for doing that each time is a pain. Not that it will probably be the way we do it anyways, but seeing if there's any automated script. I did find this:

    http://communities.vmware.com/docs/DOC-9321

  10. #10
    Bagel
    Join Date
    Jan 2009
    Posts
    1,412
    BG Level
    6

    I wrote up a wireless toggler script for my little mini machine test build based on articles I read online that might be able to provide a solution for you as well.


    I had to do this first:

    Code:
    ##Powershell Script Options Set
    
    Run Powershell in Administrator mode
    
    ##call:
    Set-ExecutionPolicy RemoteSigned

    Then modified / made a VBScript file:

    Code:
    If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    
    {   
    $arguments = "& '" + $myinvocation.mycommand.definition + "'"
    Start-Process powershell -Verb runAs -ArgumentList $arguments
    Break
    }
    
    $devid = "*DEV_0091"
    
    $status = devcon status $devid | Select-String "running"
    
    if($status -eq $null)
    {
      write-host "Enabling wireless"
      devcon enable $devid
    }
    else
    {
      write-host "Disabling wireless"
      devcon disable $devid
    }
    The lines above 'devcon' force the execution to be upraised to administrator if the script is not called to run as administrator. Of course, this means you get the little UAC popup, so it isn't without human intervention ( so, still not automated, sorry ). For what I was doing though ( toggling wireless on and off on a computer that wasn't a laptop ) this worked rather well.

  11. #11
    Nidhogg
    Join Date
    Feb 2008
    Posts
    3,790
    BG Level
    7
    FFXIV Character
    Tsugaru Mifra
    FFXIV Server
    Hyperion
    FFXI Server
    Ragnarok

    Quote Originally Posted by Meresgi View Post
    Yeah i'm not sure. I havnt dabbled much at all in VB, but I know we have a script that takes data from a simple notepad file in the form of (StudentID)(Lastname)(FirstName) and uses that to name the cloned machines. There is an error return when we run the script but i'm at home so I cant remember what exactly it was but it had to do with something "-privilege" and not being able to use the value for the variable, wondering if that's what is causing the admin to not go through. It would be easier just to clone them by hand right now, but I love troubleshooting so trying to figure out what the kink is and fix it.

    Gonna build a few VMs tonight/tomorrow and monkey around at home and see if I can make it work.

    What do you guys do for cloning a master machine into 30 or so other machines with custom names?

    We use VMWare View at the University I work for. You set up a naming convention and it clones, syspreps, renames, and joins to the domain in one fell swoop.

  12. #12
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    Quote Originally Posted by xopher View Post
    We use VMWare View at the University I work for. You set up a naming convention and it clones, syspreps, renames, and joins to the domain in one fell swoop.
    Damn that's actually really nice and a lot less hassle then doing all this crap.

  13. #13
    Nidhogg
    Join Date
    Feb 2008
    Posts
    3,790
    BG Level
    7
    FFXIV Character
    Tsugaru Mifra
    FFXIV Server
    Hyperion
    FFXI Server
    Ragnarok

    Quote Originally Posted by Meresgi View Post
    Damn that's actually really nice and a lot less hassle then doing all this crap.
    Yeah look into VMWare View or Citrix Xen Desktop. Both are really, really nice.

  14. #14
    Ridill
    Join Date
    Jul 2008
    Posts
    11,250
    BG Level
    9

    So wanted to update this because I always hate coming across links for tech issues and finding them unresolved or the last post saying "fixed it!" and not expanding.

    We found the issue, we couldn't understand what the error was with our cloning VBscript but upon looking at it more we noticed that it said "hierarchy too deep". So we checked the clones of the master machine and there were like fucking 50 chains of them, apparently each clone just cloned off of the clone before it and not from the original master, after deleting all of the extras our script runs perfect, we get all 3 user accounts and our files transfer over as well so its all legit.

    Now i'm just writing a script that will rename the computer, then change the RunOnce registry key to point to a join domain script and reboot the pc, upon the 2nd boot it will join the college domain and be all set without any interaction from the student.

    Thanks for all the help and info guys.

Similar Threads

  1. Replies: 7
    Last Post: 2011-06-06, 01:49
  2. Replies: 13
    Last Post: 2010-05-31, 00:00
  3. Replies: 6
    Last Post: 2009-02-16, 11:05
  4. Replies: 4
    Last Post: 2008-05-23, 13:35