473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Formatting device from a script on Windows

Hello, folks!
Script I am creating has to format a device - USB flash drive. I have
tried using regular DOS "format" through "os.system" - did not work
well, because DOS format requires input from user. And the script
should run without user interference.
I have taken a look at ActivePython "win32..." libraries - did not find
anything.
Ideas? Pretty please?

Regards, Mark

Sep 19 '06 #1
3 10651
this may help, you need ctypes module.

##############################
from ctypes import *

fm = windll.LoadLibrary('fmifs.dll')

def myFmtCallback(command, modifier, arg):
print command
return 1 # TRUE

FMT_CB_FUNC = WINFUNCTYPE(c_int, c_int, c_int, c_void_p)
FMIFS_HARDDISK = 0x0C
fm.FormatEx(c_wchar_p('H:\\'), FMIFS_HARDDISK, c_wchar_p('NTFS'),
c_wchar_p('title'), True, c_int(0), FMT_CB_FUNC(myFmtCallback))

Sep 19 '06 #2

weir wrote:
this may help, you need ctypes module.

##############################
from ctypes import *

fm = windll.LoadLibrary('fmifs.dll')

def myFmtCallback(command, modifier, arg):
print command
return 1 # TRUE

FMT_CB_FUNC = WINFUNCTYPE(c_int, c_int, c_int, c_void_p)
FMIFS_HARDDISK = 0x0C
fm.FormatEx(c_wchar_p('H:\\'), FMIFS_HARDDISK, c_wchar_p('NTFS'),
c_wchar_p('title'), True, c_int(0), FMT_CB_FUNC(myFmtCallback))
Thanks for info, but somehow I am getting "invalid syntax" on this.
What could go wrong?

Sep 19 '06 #3
OK, it worked. Obviosly, quick format was a bad choice.

Thanks a lot for your help!
Mark

Sep 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: nek | last post by:
Greetings, Has anyone got the latest progress on this? It hit me this time on W2K running DB2 V8.1.5. It returned the following warning: D:\Temp>db2 backup db sample to \\localhost\tape0...
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
1
by: John | last post by:
Hi We have an access db which records daily orders. We would like the orders to be downloaded to a windows mobile 2003 device via usb cradle. Drivers then take along the device and get...
7
by: BBFrost | last post by:
I'm receiving decimal values from database queries and placing them on a report page. The users want to see the following .... Db Value Display Value 123.3400 123.34...
9
by: Paul Steele | last post by:
I am writing a C# app that needs to periodically poll for cdroms and usb storage device insertions. I've looked at the WMI functions but haven't found anything all that useful. The closest is...
8
by: Tony Liu | last post by:
I am having a "Null Device is Missing" compile error when compiling a c++ project. The documentation from MSDN said it could be caused by low system resource or the user account does not have...
2
by: Rosalind Chen | last post by:
Hi, This is the first time that I use Visual Studio .NET. And I stucked in this first problem. - I created a SDK from Platform builder 4.2 that includes .Net Compact Framework. - installed...
1
by: sir_alex | last post by:
Is there any function to see how much space is left on a device (such as a usb key)? I'm trying to fill in an mp3 reader in a little script, and this information could be very useful! Thanks!
9
by: sck10 | last post by:
Hello, I have a page with an ImageButton that is used to redirect to another page. When the page first opens, everything looks as expected. However, when I click on the image, the new page...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.