Scripts Thread, Scripting an Elevated Command Prompt? in Coding and Web Development; I have software to install on lots of PC's. It's educational, and thus rubbish. After install, I need to copy ...
7th November 2012, 04:31 PM #1
Scripting an Elevated Command Prompt?
I have software to install on lots of PC's. It's educational, and thus rubbish. After install, I need to copy a file from our network to the local machine in order to make it work properly. If the command prompt isn't an Administrative one, it returns Access Denied, so I have to install the software and then RC-Run as Administrator on lots of PC's. I don't want to use RUNAS because this would require me putting my password in on each of the PC's and that kind of defeats the object.
I've tried creating a shortcut which runs as an administrator, which works, and launches an Administrative cmd with a mere pressing of a 'Yes' buttom (requiring a left-enter which can be done much quicker than typing a password 30+ times), but I can't seem to find a way to make that prompt automatically run a batch file, so that I can just remotely push the file out to x-amount of PC's and have it install via msciexec.
I've tried a batch file of M:\acmd.lnk "\\Batch Location" but that doesn't work, it just loads up a regular cmd, then an Administrative cmd, but the Administrative one doesn't run the batch file (at "\\Batch Location"). So I tried modifying the location of M:\acmd.lnk to C:\Windows\System32\cmd.exe "\\Batch Location", but that has only the same result, only with just one CMD window this time.
Any ideas? The batch file in question is simply an MSIEXEC and an XCOPY, if it matters.
IDG Tech News
7th November 2012, 04:43 PM #2
At the moment, I'm guessing your shortcut has a target of %windir%\system32\cmd.exe, yes?
Try changing the target to %windir%\system32\cmd.exe /c "\\Batch Location"
7th November 2012, 05:07 PM #3
I use AutoIT, which has a selection of runas / requireadmin commands to run various command lines as a particular user. It will compile its scripts up into a self-executing EXE file, so you don't have to distribute your password in the clear to all machines.
Originally Posted by Garacesh
9th November 2012, 02:42 PM #4
Can you install the msi via gpo and copy the file via gpp?
7th February 2013, 08:56 PM #5
How about running whatever file you need through psexec?
psexec @%labList% -h -n 5 c:\deploy\installTemp\install.bat
That's what we use....
8th February 2013, 09:39 AM #6
All good answers so far. For my 2p worth.
Open the elevated command prompt from your server (however you like) - you need only open it once and type the password once.
Then use PSExec as @MordyT described to copy the file from the remote location to the target PC's. I'm presuming the elevated command prompt uses credentials which will authenticate against the target PC's (locally or at domain level) and have access over the directory which needs to receive the extra file.
The PC's can be listed in a single text file (where @MordyT wrote @%lablist%).
If you get the command right PSExec can copy the file from the network location to the local disk and loop through the text file to work on each of the target machines.
Last edited by superfletch; 8th February 2013 at 09:41 AM.
8th February 2013, 09:43 AM #7
Just realised how old this thread is - sorry...
8th February 2013, 02:18 PM #8
Its my fault, I didn't see the date either and brought it back to life.
8th February 2013, 02:43 PM #9
It's fine, chaps, I still never figured out how to do it (we don't have any of the programs you guys suggested in our image, I was hoping for a non-third-party way but that's not always the case) and I expect this problem will rear its head again in the future. So I'm still open to ideas. Your necrobump is forgiven.
I ended up writing a small batch file to replace said file and RC-Run as Administrator on every PC.
Thank goodness for NetSupport and its mass-logon (shame the mass-run can't run as admin, 'eh?)
11th February 2013, 03:04 AM #10
PSexec shouldn't be considered 3rd party... everyone should have it in their path.
13th February 2013, 03:27 PM #11
From memory, though feel free to correct me, you don't actually need PSExec in your image on the PCs - you only need it on your own PC/server as it installs itself as a service, runs, then removes itself.
Originally Posted by Garacesh
Many people do also put it (and the rest of PStools) on their PCs, but I don't think it's needed.
13th February 2013, 03:41 PM #12
This is correct. It only needs to be on the pc running the command. I don't know about it installing/removing a service on the client though...
Originally Posted by howartp
Although, if you want psexec on each pc, you can install it with psexec after deployment..
By russdev in forum Windows
Last Post: 21st April 2009, 07:39 AM
By BatchFile in forum Virtual Learning Platforms
Last Post: 27th January 2009, 11:13 AM
By MicrodigitUK in forum Scripts
Last Post: 25th November 2008, 12:12 PM
By DaveP in forum How do you do....it?
Last Post: 21st March 2007, 11:37 AM
By ajbritton in forum Windows
Last Post: 9th August 2006, 02:04 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)