Page 1 of 1

gotadmin.vbs problem [solved]

Posted: 10 Mar 2012 02:29
by abc0502
i'm using this to run files with admin rights but it does't work here an example:

Code: Select all

@echo off
cls
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\gotadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1  >> "%temp%\gotadmin.vbs"
start /min %ComSpec% /c "%temp%\gotadmin.vbs"
copy d:\1.txt c:\1.txt


the file is copied but it keep copying it and many cmd windows pop up and disappear

[!]
if u gona try it save your work first because you might want to logoff to stop the cmd windows

Re: gotadmin.vbs problem

Posted: 10 Mar 2012 09:26
by foxidrive
Where did you get the code? It's running the batch file again and again...

You can put the copy command in another batch file and replace %~s0 with the name of the second batch file.

Re: gotadmin.vbs problem

Posted: 10 Mar 2012 10:47
by abc0502
the code was here i took it from here: http://www.dostips.com/forum/viewtopic.php?f=3&t=2790
i just took the code that i need "in case of limite privilage"

i already tried what u said but i was wondering if ther is another way but i guess i will use what you suggested.
thanks :)

Re: gotadmin.vbs problem

Posted: 10 Mar 2012 15:02
by foxidrive
You didn't include the code for

A) testing to see if admin privs are granted and
B) if so then jumping to a routine.

Re: gotadmin.vbs problem

Posted: 11 Mar 2012 01:38
by abc0502
so the code doesn't work without the rest of it
i thought because i know that i need admin privilage so i just skipped the rest
because every time i copy somthing to C:\ it say access denyed
i tryed it again with the the rest of the code and it work fine, but i think i will use the vbs file to launch the bat as u said in your last post