mvescio
asked on
MS-DOS Batch Script - Map next available drive, run application, disconnect that drive.
Hello:
I'm running an audit application. Getting permissions to run across all my companys domains/locations has proven most difficult.
I was once using a simple batch script with one line:
start \\SERVER\SHARE\APPLICATION
In an attempt to use a set login to fix the problem with permissions I had done some research and was under the impression that getting rights to the computer (logging in as another user) could only be done when mapping the drive.
This led to the issue of which letter to choose. I do not want to pick a letter as we have 9+ offices with countless clusters of people who use their own set of mapped drives for their various work. For this reason I chose to map a drive using the next available letter.
With my little knowledge of batch scripts and DOS commands, This is as far as I've gotten. I'm hoping this could help spark ideas (or if anyone has a completely different idea, or whatever, please suggest it.) You'll also notice I echo a lot of lines. This is because I do not want the actaul commands to be seen from the users point of view and when making the script, I wanted to see at what point the script had failed:
-------------------------- ---------- -
:: Auditing
@ECHO OFF
echo Connecting to server...
echo.
net use * \\SERVER\SHARE password /user:fileserver\administr ator /persistent:no
echo Initializing Audit...
echo.
start \\172.18.0.131\TIServer\Au dit32.exe \q /wait Audit32.exe
echo.
echo Looking for shared resource...
net use | FIND "\\SERVER\SHARE" > C:\Audit1.bat
echo Creating variable
echo @set drive="%%1" > C:\Audit2.bat
CALL C:\Audit1.bat
echo Removing connection
net use "drive" /del
echo Cleaning created variables...
set drive=
echo Cleaning up temporary files...
DEL C:\Audit1.bat
DEL C:\Audit2.bat
-------------------------- ---------- -
I'm running an audit application. Getting permissions to run across all my companys domains/locations has proven most difficult.
I was once using a simple batch script with one line:
start \\SERVER\SHARE\APPLICATION
In an attempt to use a set login to fix the problem with permissions I had done some research and was under the impression that getting rights to the computer (logging in as another user) could only be done when mapping the drive.
This led to the issue of which letter to choose. I do not want to pick a letter as we have 9+ offices with countless clusters of people who use their own set of mapped drives for their various work. For this reason I chose to map a drive using the next available letter.
With my little knowledge of batch scripts and DOS commands, This is as far as I've gotten. I'm hoping this could help spark ideas (or if anyone has a completely different idea, or whatever, please suggest it.) You'll also notice I echo a lot of lines. This is because I do not want the actaul commands to be seen from the users point of view and when making the script, I wanted to see at what point the script had failed:
--------------------------
:: Auditing
@ECHO OFF
echo Connecting to server...
echo.
net use * \\SERVER\SHARE password /user:fileserver\administr
echo Initializing Audit...
echo.
start \\172.18.0.131\TIServer\Au
echo.
echo Looking for shared resource...
net use | FIND "\\SERVER\SHARE" > C:\Audit1.bat
echo Creating variable
echo @set drive="%%1" > C:\Audit2.bat
CALL C:\Audit1.bat
echo Removing connection
net use "drive" /del
echo Cleaning created variables...
set drive=
echo Cleaning up temporary files...
DEL C:\Audit1.bat
DEL C:\Audit2.bat
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help :)
ASKER
I've tried so many different options and I had even tried one similar to you but now i completely see where I had gone wrong with it!
The quick responce was amazing. One less headache for a monday!