Some help required for a Batch file....

Hello,

I'm trying to make a batch file that will allow me to fill in a field with a user name for a roaming profile ownership command. Having to retype this command over and over again is tedious. So I created the following code below; but I'm clueless as to how to change this one field within the command in this batch file for each user.

here is the command: psexec -s "icacls" "d:\profiles\username.DOMAIN.V2" /grant administrators:F /t

the name is bold is the field i'd like to change on each execution of this batch program so I can breeze thru all 550 of these roaming profile recreations since we have a corrupt print driver that fucked all of the profiles on 6 TS servers including the roaming profile which is now corrupt on all of them. Takes about 25 minutes per user and 550 users ya do the math, lol!!!!

here is my code so far, any help would be appreciated.

@echo off
color 0A
title Corrupt Roaming Profile Change.
 
:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Click here for a Nude photo!
echo 2. Take Ownership of User's Roaming Profile
echo.
echo 0. Quit
echo.
 
set /p choice="Enter your choice: "
if "%choice%"=="1" goto pervert
if "%choice%"=="2" goto ownership-change
echo.
if "%choice%"=="0" exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start
 
:pervert
cls
echo your a pervert, you know it, you clicked on this option shame on you!!!
echo.
goto cancel-special
 
:ownership-change
echo.
echo.
psexec -s "icacls" "d:\profiles\nocasio.DOMAIN.V2" /grant administrators:F /t
echo roaming profile forced ownership change in progress...
echo.
 

:cancel-special
set /p cancel="Type cancel to stop action: "
if not "%cancel%"=="cancel" exit
cls
echo Action is cancelled.
echo.

pause
exit

January 10th, 2014 7:04pm

:ownership-change
echo.
echo.
psexec -s "icacls" "d:\profiles\nocasio.DOMAIN.V2" /grant administrators:F /t
echo roaming profile forced ownership change in progress...
echo.

I'm trying to figure out a way to do like a command like this, just don't know the command

if ."d:\profile\" == "d:\profile\" input field is require for last clause 

I just don't know how to script it into the code to input it into the batch field above...

Free Windows Admin Tool Kit Click here and download it now
January 10th, 2014 7:40pm

Figured it out: perhaps this will be useful for someone else...

i have a little nerd humor inside the script, lol!!!!

@echo off
color 0A
title Corrupt Roaming Profile Change.
 
:start
echo Welcome, %USERNAME%
echo What would you like to do?
echo.
echo 1. Click here for a Nude photo!
echo 2. Take Ownership of User's Roaming Profile
echo.
echo 0. Quit
echo.
 
set /p choice="Enter your choice: "
if "%choice%"=="1" goto pervert
if "%choice%"=="2" goto ownership-change
echo.
if "%choice%"=="0" exit
echo Invalid choice: %choice%
echo.
pause
cls
goto start
 
:pervert
cls
echo your a pervert, you know it, you clicked on this option shame on you!!!
echo.
goto cancel-special
 
:ownership-change
echo.
set /p profile="Enter user profile: "
IF EXIST "d:\profiles\%profile%.DOMAIN.V2" psexec -s "icacls" "d:\profiles\%profile%.DOMAIN.V2" /grant administrators:F /t
echo roaming profile forced ownership change in progress...
echo.
 

:cancel-special
set /p cancel="Type cancel to stop action: "
if not "%cancel%"=="cancel" exit
cls
echo Action is cancelled.
echo.

pause
exit

January 11th, 2014 12:43am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics