gotadmin.vbs problem [solved]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

gotadmin.vbs problem [solved]

#1 Post by abc0502 » 10 Mar 2012 02:29

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
Last edited by abc0502 on 12 Mar 2012 00:30, edited 1 time in total.

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: gotadmin.vbs problem

#2 Post by foxidrive » 10 Mar 2012 09:26

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.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: gotadmin.vbs problem

#3 Post by abc0502 » 10 Mar 2012 10:47

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 :)

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: gotadmin.vbs problem

#4 Post by foxidrive » 10 Mar 2012 15:02

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.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: gotadmin.vbs problem

#5 Post by abc0502 » 11 Mar 2012 01:38

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

Post Reply