How to run as admin? - superuser

How to make this bat script run as admin either on the local computer as a scheduled task or startup up scrip?
forfiles -p "C:\ProgramData\ESET\ESET Endpoint Antivirus\Logs\eScan" -s -m *.dat /D -0 /C "cmd /c del #path"

If you are just running this once, and not automating a number of scripts, you can just hold shift and right click to run as admin.

Related

Batch script does not close cmd after execution

I have the below code which starts the siebel tools from a batch script:
#ECHO OFF
D:
CD D:\Siebel\8.1.1.16.0\Tools\BIN\
ECHO Starting Siebel Tools
siebdev.exe /c D:\Siebel\8.1.1.16.0\Tools\CFG\tools.cfg /d DataSrc /u ADMIN /p PASSWORD
cmd
But this does not close the command prompt. Please help.
this alone should be fine, without cmd in the end line
#ECHO OFF
CD /d D:\Siebel\8.1.1.16.0\Tools\BIN\
ECHO Starting Siebel Tools
siebdev.exe /c D:\Siebel\8.1.1.16.0\Tools\CFG\tools.cfg /d DataSrc /u ADMIN /p PASSWORD
just to add,
/d can be used after cd instead of D: and then using cd

BATCH Preventing users from opening file from outside the program?

I have a plugin system on a program written in batch, as follows; (thanks to https://stackoverflow.com/users/3536342/davidpostill)
:plugindragon
echo.
echo Plugins
echo ==============
dir /b plugins\*.cmd
echo.
echo Enter the name of the plugin you want to run.
set /p plugin=root/plugins/plugin_dragon.jr#Root:~$
start "" plugins\%plugin%
goto root
Is there any way to prevent users of my program from opening said plugins without running the pluginDragon script? As in they can't just directly go into the plugins folder and double click the applications (as they're all written in batch). They'd need to use the "terminal" window to open them, and only that.
Here is a modification of your script that does the following:
Makes the files hidden and system files using attrib
Changes the permissions on the files to make them unopenable using icacls
:plugindragon
echo.
echo Plugins
echo ==============
dir /b plugins\*.cmd
echo.
echo Enter the name of the plugin you want to run (Exclude extension).
set /p plugin=root/plugins/plugin_dragon.jr#Root:~$
:: Grant permission to access file
icacls "plugins\%plugin%.cmd" /grant everyone:F /T /C /Q>nul 2>&1
:: Unhide the file
attrib -h -s -r -a "plugins\%plugin%.cmd" >nul
start /wait "" plugins\%plugin%.cmd
:: Hide the file
attrib +h +s +r +a "plugins\%plugin%.cmd" >nul
:: Denies access to the file
icacls "plugins\%plugin%.cmd" /deny everyone:F /T /C /Q>nul 2>&1
goto root

i need help understanding this batch script

i dont under stand the
forfiles -p
or the
/C "cmd /c del #path"
what do they do they mean
Basically it does the following.
For each files in c:\test that contains .jpg format and are 0 days old or older will be deleted.
Commands explained...
Forfiles -p : Select a file (or set of files) and execute a command on each file. -p: The Path to search (default=current folder)
/C command : The command to execute for each file.
Wrap the command string in double quotes.
Default = "cmd /c echo #file"
CMD /c : Start a new CMD shell and run Command and then terminate
Del : Delete
#path : Full path of the file.
More details at http://ss64.com/

Sikuli multiple scripts batch

I'm trying to create a batch in Windows 7 that will open at least two Sikuli scripts in sequence. I've tried using the solutions found here and couldn't get them to work. This is the batch command I've used:
cmd /C C:\path\Sikuli\runIDE.cmd -r C:\path\Sikuli\all.sikuli
cmd /C C:\path\Sikuli\runIDE.cmd -r C:\path\Sikuli\sikuli_test.sikuli
I've also tried:
start /i /b /wait C:\path\Sikuli\runIDE.cmd -r :\path\Sikuli\all.sikuli
start /i /b /:\path\Sikuli\runIDE.cmd -r :\path\Sikuli\sikuli_test.sikuli
The first Sikuli script executes but the second one does not. The problem seems to be within Sikuli IDE opening in cmd, which once it initializes doesn't allow any more commands in the batch to execute as Sikuli's monitoring process takes over the cmd prompt.
start /wait will wait for the executable to exit before continuing. Remove the /wait switch and batch will proceed to your second command.
have you tried
cd C:\SikuliX && runScript.cmd -r C:\path\Sikuli\all.sikuli
cd C:\SikuliX && runScript.cmd -r C:\path\Sikuli\sikuli_test.sikuli
What I did is I have two batch files to call the sikuli files ("Dummy1.sikuli" and "Dummy2.sikuli").
And then I have a 3rd batch file that will call all other batch files.
Sikuli opens by using the command window, and this way both .sikuli files have a command window.
My examples are all located in:
C:\Dummy
Files located here:
Dummy1.sikuli
Dummy2.sikuli
Dummy1.bat
Dummy2.bat
RunDummies.bat
Dummy1.bat
#ECHO OFF
REM Run Dummy1.sikuli
C:\Sikuli\runIDE.cmd -r C:\Dummy\Dummy1.sikuli
Dummy2.bat
#ECHO OFF
REM Run Dummy2.sikuli
C:\Sikuli\runIDE.cmd -r C:\Dummy\Dummy2.sikuli
RunDummies.bat
#ECHO OFF
start cmd.exe /C Dummy1.bat
start cmd.exe /C Dummy2.bat

Opening cmd using psexec to a specific remote directory

The goal is to delete the temporary internet files on a remote computer.
start psexec -u domain\username -p password -s \\xxx.xxx.xxx.xxx
cmd cd C:\Documents and Settings\USERACCOUNT\Local Settings\Temporary Internet Files
Which is connecting to the remote computer but just opening to c:windows\system. I am then able to cd to that directory and use del /f /s /q *.* to delete all the problem files.
I tried using psexec \\computer cmd /c del fileName but had even less luck with that.
Why bother cd'ing to directory first? This should work:
psexec \\1.2.3.4 -u "domain\username" -p "password" cmd /c del /f /s /q "C:\Document and Settings\USERACCOUNT\Local Settings\Temporary Internet Files"
I finally got it to work using
psexec -u domain\user -p password \\xxx.xxx.xxx.xxx -s cmd /c rd "C:\Documents and Settings\%USERACCOUNT%\Local Settings\Temporary Internet Files\Content.IE5\" /s /q
which connects to the remote server, goes straight to the directory I want and proceeds to delete the particular temp internet files folder that's causing issues without bothering me at all.
Your command is okay but missing the server name
psexec \\\servername -u ...
Use the below command to create a directory in remote location.
psexec \\\IPAddress -u username -p Password cmd /c mkdir c:\testfolder

Resources