.bat run as admin but I need logon user
Moderator: DosItHelp
Re: .bat run as admin but I need logon user
I have no idea what FIRST BAT and SECOND BAT are.
I know you are trying to explain it buy BE VERY SPECIFIC!
I know you are trying to explain it buy BE VERY SPECIFIC!
Re: .bat run as admin but I need logon user
First BAT install/copy/open programs that don't need admin powers.
Second BAT instal/copy/openl programs that need admin powers.
In first BAT I open Second (with admin rights)
And when second don't finish, first must wait
If you still dont udnerstand i copy source.
Second BAT instal/copy/openl programs that need admin powers.
In first BAT I open Second (with admin rights)
And when second don't finish, first must wait
If you still dont udnerstand i copy source.
Re: .bat run as admin but I need logon user
Krump wrote:If you still dont udnerstand i copy source.
I asked for that a couple of posts back.
Re: .bat run as admin but I need logon user
First Bat:
Second Bat (asadmin.bat)"
Code: Select all
@echo off
mode con:cols=80 lines=25
echo Instalator Konfiguracji Uzytkownika Koncowego
:AUTORIZATION
echo.
echo ________________________________________________
set /p login_usera=Podaj login administratora:
echo.
runas /user:domain.net\%login_usera% "D:\Tablety\asadmin.bat"
if "%ERRORLEVEL%"=="1" goto AUTORIZATION
echo.
echo Konfiguracja OutLook
call "D:\Tablety\Sygnatura.docx"
call "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Office 2013\Outlook 2013.lnk"
echo.
echo Instalacja T-Smart'a
copy "D:\Tablety\T-Smart.url" "%userprofile%\Desktop\"
call "%userprofile%\Desktop\T-Smart.url"
echo.
echo Odinstalowywanie Aplikacji PowerShell
Powershell.exe -executionpolicy remotesigned -File "D:\Tablety\PowerShell.ps1"
echo.
echo Konwertowanie Ekranu Startowego
copy "D:\Tablety\appsFolder.itemdata-ms" "%LocalAppData%\Microsoft\Windows\"
copy "D:\Tablety\appsFolder.itemdata-ms.bak" "%LocalAppData%\Microsoft\Windows\"
echo.
echo Zakończono konfiguracje tabletu %computername%.
pause
Second Bat (asadmin.bat)"
Code: Select all
@echo off
mode con:cols=80 lines=25
FOR /F "tokens=2 delims='='" %%A in ('wmic ComputerSystem Get username /value') do SET user=%%A
set user=%user:*\=%
echo Instalator Konfiguracji Uzytkownika Koncowego
echo.
echo Instalacja Bluetooth'a
call D:\Tablety\5130-64Bit_Network_Driver_GX371_WN_3.7.2.59_A01.EXE
echo.
echo Instalacja TeamVier'a
call "D:\Tablety\TeamViewer_Host_Setup.exe"
echo.
echo Instalacja CDM
call "D:\Tablety\CDM20814_Setup.exe"
echo.
echo Instalacja DirectAccess
call "D:\Tablety\Microsoft_DirectAccess_Connectivity_Assistant_x64.msi"
pause
echo.
echo Wyłączanie Sklepu Windows
del "C:\Users\%user%\Desktop\TeamViewer 9 Host.lnk"
del "C:\Users\%user%\Desktop\Adobe Reader X.lnk"
call "D:\Tablety\set.reg"
REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband /F
taskkill /f /im explorer.exe
start explorer.exe
pause
echo.
echo GPUpdate
gpupdate /force
Re: .bat run as admin but I need logon user
You can get rid of the SET command I told you to use earlier and you can just use this. You can use multiple delimiters with the FOR /F command.
Code: Select all
FOR /F "tokens=3 delims==\" %%A in ('wmic ComputerSystem Get username /value') do SET user=%%A
Re: .bat run as admin but I need logon user
Ok, thanks it's will halpful in the future.
But now important for me is open second bat as admin in such a manner that the first wait for second finish.
But now important for me is open second bat as admin in such a manner that the first wait for second finish.
Re: .bat run as admin but I need logon user
Give this a try. Not sure if it will work or not.
Code: Select all
runas /user:domain.net\%login_usera% "Cmd /C \"D:\Tablety\asadmin.bat\""
Re: .bat run as admin but I need logon user
We tried to tackle this problem 4 years ago on the forums. It never did get resolved.
viewtopic.php?f=3&t=1181
You may have to put in some type of convoluted LOOP to check for the second batch file still running in TASKLIST. Once you don't see it running in tasklist then continue with the first batch file.
viewtopic.php?f=3&t=1181
You may have to put in some type of convoluted LOOP to check for the second batch file still running in TASKLIST. Once you don't see it running in tasklist then continue with the first batch file.
Re: .bat run as admin but I need logon user
Try something like this:
The errorlevel after this line may be from runas and not the batch file.
Code: Select all
runas /user:mydomain.net\%login_usera% "start "" /w %comspec% /c \\Tablety\asadmin.bat"
The errorlevel after this line may be from runas and not the batch file.
Re: .bat run as admin but I need logon user
Krump wrote:Ok, thanks it's will halpful in the future.
But now important for me is open second bat as admin in such a manner that the first wait for second finish.
You can open second bat as admin (elevated permissions) with this power shell script added to your .bat
xbox
Code: Select all
(NET FILE||(powershell -command Start-Process '%0' -Verb runAs -ArgumentList '%* '&EXIT /B))>NUL 2>&1
Re: .bat run as admin but I need logon user
Squashman your way don't work.
foxidrive your way don't work too.
Xboxer your way work but wrong in this situation
foxidrive your way don't work too.
Xboxer your way work but wrong in this situation
Re: .bat run as admin but I need logon user
Krump wrote:Squashman your way don't work.
foxidrive your way don't work too.
Xboxer your way work but wrong in this situation
Like I said in my previous post, we have previously tried to find a solution for this problem in the past. But, maybe you can elaborate more on what is wrong with Xboxer's solution. You can't just make an ambiguous statement like that without providing some kind of detailed feedback.
Re: .bat run as admin but I need logon user
Ok, because it autorization, but don't want start the proces.
Re: .bat run as admin but I need logon user
What version of Windows are you running this on?
You may be able to use the WAITFOR command if you are using a newer version of Windows.
You may be able to use the WAITFOR command if you are using a newer version of Windows.
Re: .bat run as admin but I need logon user
I start this bat on Win 8.1.
WAITFOR?
How I can use this command?
WAITFOR?
How I can use this command?