krovax Posted June 7, 2007 Posted June 7, 2007 Hi guys, I'm a total newb in scripting and I hae the following need:I want to use Winpe 2.0 to wipe hardrive with diskpart and have a log of that. I want my log file to have the serial number of the drive as file name.I know that there is no good way to get the serial number of HDD (IDE or SATA) so I am using a bar code reader.The script should pop a text box so I can scan the serial number on the hard drive and keep that value to name my log file. here is a script someone made from me but we are unable to find what it's not working:Dim ReponseDim AbsPath:AbsPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "") ' This variable DOES have a trailing '\' Reponse = inputbox("write a value,Cancel or no value to exit the script","Diskpart")If Answer = "" Then Wscript.QuitEnd ifCall ExecuteProg(AbsPath & "diskpart ", Answer)Sub ExecuteProg(PathAndProgName, Var1)Set WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run PathAndProgName & "/s diskpart.txt>z:\" & Var1 & ".txt"End sub(there was a bit of french in here so I tried to rename it to english)in my startnet.cmd there is a command to map a drive to a network share then I am running the vbs.The vbs is supposed to start diskpart, run the script, and redirect the output to the mapped drive and use the value as a log file name.Now when we execute the vbs dispart is running but it's not using the the clean all command that he is supposed to do and there is no log file created.Thx for your help and don't be shy to ask me question if there is something bizarre (english is my second language so I'm trying to be as clear as I can)
krovax Posted June 7, 2007 Author Posted June 7, 2007 (edited) This is my problem, I don't have any error.Just wanted to see if the script was looking fine (cause like I said I am a total nub in vbs).The only thing I can see is that there is another command prompt opening and there is a dispart display then it shutdown and nothing more, not even a log is created. The dispart cclean all command should take about 10 minutes and I should have a log on my mapped drive. Edited June 7, 2007 by krovax
jondercik Posted June 7, 2007 Posted June 7, 2007 (edited) I would do something different for the choice box,something like choice=MsgBox("Do you want to run diskpart now?",3,"Run diskpart?") If choice = 6 Then Call ExecuteProg(AbsPath & "diskpart ", Answer) End If Edited June 7, 2007 by jondercik
IcemanND Posted June 7, 2007 Posted June 7, 2007 Unless you are going to call the same diskpart script multiple times on the same machine there is no need for a subroutine. Also your variable name keeps changing. The value from your input box is put into 'Response' but then you check the value for input by looking at 'Answer' and then try naming the file using 'Var1'. These should all point to the same variable name.Dim ReponseDim AbsPathDim AnswerDim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")Answer = ""AbsPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")Answer = inputbox("write a value,Cancel or no value to exit the script","Diskpart")If Answer = "" Then Wscript.QuitEnd ifWshShell.Run AbsPath & "diskpart.exe /s diskpart.txt>z:\" & Answer & ".txt"
jondercik Posted June 7, 2007 Posted June 7, 2007 Bah how did I miss that. I like my version better anyway
krovax Posted June 7, 2007 Author Posted June 7, 2007 (edited) And how yould you guys write what I want?Input box, take that value entered and use it in that way diskpart /s diskpart.txt>z:\"value".txt*I didn't refresh before posting, sorry Edited June 7, 2007 by krovax
krovax Posted June 7, 2007 Author Posted June 7, 2007 (edited) Still same problem, the script start, another windows open and close really fast and there is no text file create on the share and no error message.If anyone have an idea of how we could correct that or do it another way that would be awesome I was thinking that maybe I could save the file on the ram drive (x:) into "value".qwe and then copy *.qwe on z:What do you guys think of that? Edited June 7, 2007 by krovax
IcemanND Posted June 7, 2007 Posted June 7, 2007 if you open a CMD window an run the diskpart script manually does it work?
krovax Posted June 8, 2007 Author Posted June 8, 2007 Yes I have tried that before but my problem was that I had to give a name for the log file and it was always the same name.I know I could have change the name after but when I will wipe 10 HDD at the same time all my file will write over each other.
IcemanND Posted June 8, 2007 Posted June 8, 2007 try thisDim ReponseDim AbsPathDim AnswerDim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")Answer = ""AbsPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")Answer = inputbox("write a value,Cancel or no value to exit the script","Diskpart")If Answer = "" Then Wscript.QuitEnd ifWshShell.Run "cmd /k " & chr(34) & abspath & "diskpart.exe" & chr(34) & " /s diskpart.txt>c:\" & Answer & ".txt"
krovax Posted June 8, 2007 Author Posted June 8, 2007 Woot!!!!!!!!When I tried the last script it didn't worked (I had no access to c:) but then I changed the path to Z: and the file was there.Thank you so much guys!!!!For my personnal learning, what is abspath? and how to work with it?
jondercik Posted June 8, 2007 Posted June 8, 2007 I wouldnt use the following line, I would, and actually do the followingDONT USEAbsPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")UsecurrentDirectory = WshShell.currentDirectory & "\"Just my two centsJim
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now