• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Pretty simple batch file question for the vets...

warcrow

Lifer
Due to a series of unfortunate events (work politics, I'm sure you guys can understand) I have to impliment am automated system that disables the mounting of USB thumb drives on several loaner machine during their start-up process.

The goods news is I have a working batch file that will do this.

The bad news is actually getting this batch file to run on a few machines before the user logs in.

Since I'm not a programmer of any sorts (I'm mostly a hardware guy), I only have experience with working in Basic--here is what I've come up with so far (hold laughter till the end please):


Once we throw an image on a machine, our level one tech guys run a batch file (migration.bat) that configures, installs and tweaks the machines for our network enviroment. In the batch file (Image_Config.bat) I plan to make a call to our existing USB_Disable.bat file.

That batch, USB_Disable.bat, is suppose to make a comment in the registry to run the last batch file (Perm_Off.bat) so that they're disabled every time the machine is booted up.


Image_Config.bat I have this in there:

"if %computername% == <computername> call c:\migration\SetACL\USB_Reg_Disable.bat"


USB_Reg_Disable.bat:

SET KEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

REG ADD %KEY% /V TITLE /D "USB Drives Disable" /f

REG ADD %KEY%\01 /VE /D "Disable USB Thumb Drives" /f
REG ADD %KEY%\01 /V 1 /D "c:\migration\SetACL\Perm_off.bat" /f



...the problem is that it's not working. I know "Perm_off.bat" works because I've tested it seperately.

Ok, please stop laughing at me now! Help?



For refference, there are 3 batch files:

migration.bat - Runs after an image is pushed.
USB_Reg_Disable.bat - Makes registry entries to make call to perm.bat
Perm_off.bat - disabled the use of USB thumb drives.
 
Wow, nested batch file nightmare! haha....

I'd bet it's a permission problem, depending on what perm_off.bat does - a user does not have permission to edit HKLM i dont believe, so when they log in and it runs it cant remove the key.
 
Originally posted by: WannaFly
Wow, nested batch file nightmare! haha....

I'd bet it's a permission problem, depending on what perm_off.bat does - a user does not have permission to edit HKLM i dont believe, so when they log in and it runs it cant remove the key.

When I tested this I logged in with my ellevated account.
 
If I may offer a silly suggestion, do you need more quotes? Like this:

if "%computername%" == "<computername>" call c:\migration\SetACL\USB_Reg_Disable.bat

I believe any spaces in computername would make that necessary.
 
Originally posted by: Ken g6
If I may offer a silly suggestion, do you need more quotes? Like this:

if "%computername%" == "<computername>" call c:\migration\SetACL\USB_Reg_Disable.bat

I believe any spaces in computername would make that necessary.

We're actually just using the host name (one word), but I'm wondering if I need quotes around the file path?
 
Originally posted by: warcrow
Originally posted by: WannaFly
Wow, nested batch file nightmare! haha....

I'd bet it's a permission problem, depending on what perm_off.bat does - a user does not have permission to edit HKLM i dont believe, so when they log in and it runs it cant remove the key.

When I tested this I logged in with my ellevated account.

right, which would confirm what I'm saying, test it using only a user account.

Post whats in perm_off.bat
 
surely there is an easier way to accomplish this.

you can right to the registriy to disable USB flash drives with a few lines of MFC (c++ / vb) code... and then just put that EXE in

HKLM/Software/microsoft/windows/currentverison/run
 
Originally posted by: WannaFly
Originally posted by: warcrow
Originally posted by: WannaFly
Wow, nested batch file nightmare! haha....

I'd bet it's a permission problem, depending on what perm_off.bat does - a user does not have permission to edit HKLM i dont believe, so when they log in and it runs it cant remove the key.

When I tested this I logged in with my ellevated account.

right, which would confirm what I'm saying, test it using only a user account.

Post whats in perm_off.bat

 
Originally posted by: sao123
surely there is an easier way to accomplish this.

you can right to the registriy to disable USB flash drives with a few lines of MFC (c++ / vb) code... and then just put that EXE in

HKLM/Software/microsoft/windows/currentverison/run

Unfortunately I've never touched C++ or VB.
 
Back
Top