What's new
Carbonite

South Africa's Top Online Tech Classifieds!
Register a free account today to become a member! (No Under 18's)
Home of C.U.D.

How to run batch file as admin from standard user Win7

Alien

Epic Member
Rating - 100%
46   0   0
Joined
Sep 6, 2011
Messages
2,560
Reaction score
4
Points
3,085
Age
34
Location
Howick, KZN
Hey guys

I have been struggling to find anything on this so i'm hoping that someone here may be able to help.

The new company i work for has alot of legacy programs which still need to stay legacy :(. in the next few years they will be converting it to windows applications i hope, but for now i need to find a workaround and get these running. The obvious right click properties and run as admin wont work here and i would like to keep the users as standard users without admin privileges for security reasons.

I have tried runas to some extent but that needs to reference an external program. I will try create a batch file to run the batch file but that seems a little silly and i could run into the same problems. unless there is another way to map a usb printer to the lpt port so i don't need admin rights.
the reason they didnt have trouble with this before now was because all users have admin rights and are running xp on p4's and celerons and we are upgrading the pcs to win7 and i3's

any help would be awesome!
 
running batch2 from runas in batch1 is not working it seems. anyone have any ideas?
 
just briefly what does the batch file do?

worst case scenario is you could log in as admin, if it's stuff like printers and stuff, it should run the command then that's it unless it needs to be run constantly.

if thats the case.

you could look into a start up script for the users with the commands that needs to be run, this will kick off every time the user logs in. in a start up script you should be able to dictate who you run the command as.

hope it helps.
 
just briefly what does the batch file do?

worst case scenario is you could log in as admin, if it's stuff like printers and stuff, it should run the command then that's it unless it needs to be run constantly.

if thats the case.

you could look into a start up script for the users with the commands that needs to be run, this will kick off every time the user logs in. in a start up script you should be able to dictate who you run the command as.

hope it helps.

the batch file maps a usb printer to a lpt port then it runs some dbl program used for accounting. I am trying to script this so that users dont need to change accounts
 
You can try using PSTools (PsTools), it's a great tool.
The only thing is, you will need another machine with administrative rights to run it across the network (if there even is one).
 
You can try using PSTools (PsTools), it's a great tool.
The only thing is, you will need another machine with administrative rights to run it across the network (if there even is one).

Ill give that a try tomorrow. there is a network its connected to. and actually running the batch over the network already(stored on a local pc). So as long as the "server" has admin rights then it will work?
 
lets see if the above solution helps if not we can investigate how to script the start up script for you.
 
You can try using PSTools (PsTools), it's a great tool.
The only thing is, you will need another machine with administrative rights to run it across the network (if there even is one).
Looks like this only will allow me to execute programs on a remote machine, from the remote machine. which is pretty cool and i will more than likely use this for something else :D but the batch file i need to run remotely requires user input and eventually prints to a local printer. as a result, it needs to show the UI on the users pc

lets see if the above solution helps if not we can investigate how to script the start up script for you.
back to the drawing board i think
 
alright, lets get crunching. first things first. is everything you need to do already scripted in the batch file?

*sorry admins for the double post wasnt thinking.*
 
Last edited:
what we can try here is having 2 bat files created then getting the one to run the other after it has elevated the permissions.

so first create a bat file that will contain:
runas /user:SomeLocalAdminAccount c:\Users\MyUser\StartupWhat.bat

the you should be able to copy paste the command as is but change the "user", "myUser", "starupwhat.bat"

to your information.

next , if you have the bat file already scripted then just copy it to the directory of the above command.

put the startas.bat in the start up. what it should do is elevate the user to admin for the script to run the bat file you have already.


hope it helps.

check back here if not.
 
Two options:

1. Try running the batch file under scheduler at bootup using Admin account with full rights.
2. DOSBOX. Not the normal one. There are some ones with better lpt support. I'll try find if the above does not work.
 
Last edited:
what we can try here is having 2 bat files created then getting the one to run the other after it has elevated the permissions.

so first create a bat file that will contain:
runas /user:SomeLocalAdminAccount c:\Users\MyUser\StartupWhat.bat

the you should be able to copy paste the command as is but change the "user", "myUser", "starupwhat.bat"

to your information.

next , if you have the bat file already scripted then just copy it to the directory of the above command.

put the startas.bat in the start up. what it should do is elevate the user to admin for the script to run the bat file you have already.


hope it helps.

check back here if not.

Tried this on friday to no avail. \\remote-pc\x.bat is the dbl program. and that is what needs the elevated permissions to map local usb printer to ltp port on local machine.
I ran the elevate permissions batch from \\local-machine\desktop\y.bat then referenced the \\remote-pc\x.bat after elevation.

had two problems.
a) \savecred wouldnt allow input of password(after username input + enter, then cant seem to type next to password input)
b) found a way around that(by adding the command to a shortcut like this "C:\Windows\System32\runas.exe /savecred /user........"), and seemed to execute \\remote-pc\x.bat, but window closed as fast as it opened since im not sure how to append multiple commands in a shortcut(for pause command). tried semi-colon then gave up
 
Option 3:
WinPrint | Free Home & Education software downloads at SourceForge.net

Option 2 (see previous post):
parallel port - Using a printer in Dosbox - Super User

I have used above successfully with an old old DOS program.

The dos program doesn't print the screen. it uses data from a separate server(not mentioned yet), formats it correctly and then prints that. so not sure if dosbox will accept all the other commands or if winprint will work, unless it watches the lpt port the forwards the print job because the printer is actually usb, not parallel.

Thinking about trying the scheduled thing but will have to do that on each machine that runs the same program..assuming it even works since the program that this is all for...is in-house
 
just to let you know if the dos box comes up asking for a password it's working. passwords dont display when typing them in, not even dots or asterisk's. even though it looks like you typing nothing just type the password then enter it will move on to the next command
 
just to let you know if the dos box comes up asking for a password it's working. passwords dont display when typing them in, not even dots or asterisk's. even though it looks like you typing nothing just type the password then enter it will move on to the next command
hmm.odd.wonder why it never worked then. tried admin, standard and remote credentials and kept failing
Im assuming the program is a dos based application?
yes
tried net use lpt?
yes

I may have a possible solution which i have yet to try. Splitting the batch file into the net use part(to be placed in startup with some others for mapped drives) and the rest of it(better bloody not need admin privileges). unfortunately this means that i will have to configure every pc uniquely in terms of which printers they use
 
Not necessarily, give all the shares the same name then in the batch script

net use lpt1 \\%COMPUTERNAME%\{sharename}

which you can then run on startup
 
Not necessarily, give all the shares the same name then in the batch script

net use lpt1 \\%COMPUTERNAME%\{sharename}

which you can then run on startup
already using that command sunshine :p. see my above post. unless you are talking about using that exact syntax. which wont work either since some pc's share a printer
 
So it looks like net use lpt needs higher permissions than admin rights :/. tried it on the startup and still wouldnt work. then tried to elevate and fell short because it wouldnt save credentials once again.although this time it did actually accept my password... so might just be my syntax
 
damb.just realised why it didnt work. to elevate permissions you have to reference a program.so maybe its back to batch 1 & batch 2 with batch 1 being in startup
 

Users who are viewing this thread

Back
Top Bottom