Katler
Katler

Reputation: 507

More Scripting using .vbs and .bat

Thanks again in advance for the help. I made another post about scripting but due to them being different questions, I didn't want to combine them.

So I want to make an Autorun.inf file that runs when I connect my USB. The USB will start in a "readonly" state. My Scripts will be on the USB and basically will run a command to clear the attribute of readonly using diskpart, which will then find a specified path. It will then copy all contents of the specified path onto the USB. Once completed it will run diskpart in order to set the attribute to readonly one again. And then finally, it will set the reg key for USB Autoplay disabled so no other USB's can connect to the machine.

I have scripted everything, it all works... But I want to know if I can combine them using VBS or even a Normal Batch into 1 file.

My scripts are as follows.

@echo    
diskpart.exe /s C:\Users\Jarryd\Desktop\clear.txt    
set source=C:\Users\Jarryd\Desktop\Backup\IRIS     
set destination=E:\IRIS   
xcopy %source% %destination% /y    
timeout 5
set source=C:\Users\Jarryd\Desktop\Backup\Face     
set destination=E:\Face   
xcopy %source% %destination% /y
diskpart.exe /s c:\Users\Jarryd\Desktop\set.txt
pause    

The 2 text files that give the diskpart.exe commands

clear attribute

Select Disk 1
attributes disk clear readonly

set attribute

Select Disk 1
attributes disk clear readonly

and then finally the script to disable AutoPlay of USB's

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR]
"Start" = dword:00000004

I use a vbs script to run the reg key script so that it is hidden.

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "regedit /s C:\Users\John\Desktop\ClosePorts.reg" ,1 ,True
Set WshShell = Nothing

So yeah basically all of that into 1 vbs script or any script would be great.

Thanks in advance

Upvotes: 1

Views: 598

Answers (1)

Katler
Katler

Reputation: 507

I found a script that would do this and tried modifying it the way I need it, but it is too advanced for me and honestly too difficult so I am going to go with the suggest from @Tomalak and just stick to the batch file script.

Thanks

Upvotes: -1

Related Questions