Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
abc0502
- Posts: 1007
- Joined: 26 Oct 2011 22:38
- Location: Egypt
#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: 6031
- Joined: 10 Feb 2012 02:20
#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.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#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
#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