Reputation: 13
Hello im making unhide usb files i modify konboot usb installer to usb unhide
CMD cscript //Nologo USB.vbs>unhide.bat
Wscript.Echo "attrib -s -h -r /s /d "& SingleLogicalDisk.DeviceID,"\*.*"
the output attrib -s -h -r /s /d F:(have space here)*.*
i need no space on F:(Here)*.*
my final output i want attrib -s -h -r /s /d F:*.*
vbscript
Dim query
Dim WMBIObj
Dim AllDiskDrives
Dim SingleDiskDrive
Dim AllLogicalDisks
Dim SingleLogicalDisk
Dim AllPartitions
Dim Partition
Dim result
Dim textmsg
Dim wshShell
Dim FileObj
Dim Counter
set FileObj = CreateObject("Scripting.FileSystemObject")
set wshShell = wscript.createObject("wscript.shell")
Set WMBIObj = GetObject("winmgmts:\\.\root\cimv2")
Set AllDiskDrives = WMBIObj.ExecQuery("SELECT * FROM Win32_DiskDrive where InterfaceType='USB'") '
For Each SingleDiskDrive In AllDiskDrives
counter = counter + 1
query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + SingleDiskDrive.DeviceID + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition"
Set AllPartitions = WMBIObj.ExecQuery(query)
For Each Partition In AllPartitions
query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + Partition.DeviceID + "'} WHERE AssocClass = Win32_LogicalDiskToPartition"
Set AllLogicalDisks = WMBIObj.ExecQuery (query)
For Each SingleLogicalDisk In AllLogicalDisks
textmsg = "============================================" & VbCr & _
"DeviceID: " & SingleDiskDrive.DeviceID & VbCr & _
"Logical Drive: " & SingleLogicalDisk.DeviceID & VbCr & _
"Model: " & SingleDiskDrive.Model & VbCr & _
"Manufacturer: " & SingleDiskDrive.Manufacturer & VbCr & _
"============================================" & VbCr & _
"Would you like to use this drive as destination?" & VbCr & _
"Warning, disk data may be overwritten"
result = MsgBox(textmsg, vbQuestion + vbOKCancel, "USB")
if result = vbOk Then
WScript.Echo "echo DeviceID: " & SingleDiskDrive.DeviceID
WScript.Echo "echo Logical Drive: " & SingleLogicalDisk.DeviceID
WScript.Echo "echo Model: " & SingleDiskDrive.Model
WScript.Echo "echo Manufacturer: " & SingleDiskDrive.Manufacturer
Wscript.Echo "attrib -s -h -r /s /d "& SingleLogicalDisk.DeviceID,"\*.*"
wshShell.Run "unhide.bat"
WScript.quit
MsgBox "Your USB is ready!", vbInformation + vbOKOnly, "USB"
WScript.quit
End If
Next
Next
Next
if counter = 0 Then
MsgBox "No USB disks detected or unknown error!", vbCritical + vbOkOnly, "USB"
End If
Upvotes: 1
Views: 129
Reputation: 2442
In this line:
Wscript.Echo "attrib -s -h -r /s /d "& SingleLogicalDisk.DeviceID,"\*.*"
You need to concatenate the strings "attrib -s -h -r /s /d "
, SingleLogicalDisk.DeviceID
and "\*.*"
You are using ,
instead of &
to concatenate the second and third strings. It should actually be:
Wscript.Echo "attrib -s -h -r /s /d "& SingleLogicalDisk.DeviceID & "\*.*"
When you use ,
instead of &
, the third string is considered as another argument to the echo
method. So, it adds a space between the arguments in the output.
From: Echo Method
Each displayed item is separated with a space character.
Upvotes: 2