|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Formatting floppy using VBScript on Win XP
The following VBScript will pop up the Format Floppy dialog on Win98:
Set wshshell = WScript.CreateObject ("WScript.shell") wshshell.Run ("C:\WINDOWS\RUNDLL32.EXE Shell32.DLL,SHFormatDrive"), 1, true I want to make this script work on Windows XP. I have confirmed that if I enter "RUNDLL32.EXE Shell32.DLL,SHFormatDrive" into the Run dialog that the Formot Floppy dialog pops up. But when I run the following VBScript nothing happens: Set wshshell = WScript.CreateObject ("WScript.shell") wshshell.Run ("C:\WINDOWS\System32\RUNDLL32.EXE Shell32.DLL,SHFormatDrive"), 1, true I have even tried removing the "C:\WINDOWS\System32" and that had no effect. Anybody have any idea what I am doing wrong, or have another way to get the Format Floppy dialog to pop up in WindowsXP using VBScript? Thanks much, Jason |
|
#2
|
|||
|
|||
|
U must correct the shell("C:\WINDOWS\System32\RUNDLL32.EXE Shell32.DLL,SHFormatDrive") is right!Run it in the command line is the way to correct it!
Some system32 path is "C:\WINDOWS\System32\". |
|
#3
|
|||
|
|||
|
Cleverpig,
I'm not exactly sure what you are saying. I have confirmed that rundll32.exe and shell32.dll are in c:\windows\system32. I have tried running "C:\windows\system32\rundll32.exe shell32.dll,SHFormatDrive" in the command prompt, but also nothing happens. But, remember if I type "rundll32.exe shell32.dll,SHFormatDrive" in the Start/Run dialog, then I do get the Format Floppy dialog. This makes no sense to me. Basically, I am looking for any way to get the Format Floppy dialog to pop up in Windows XP using VBScript. I do appreciate any ideas or leads. Thanks! Jason |
|
#4
|
|||
|
|||
|
You have some extra parentheses, try this
Set wshshell = WScript.CreateObject ("WScript.shell") wshshell.Run "C:\WINDOWS\RUNDLL32.EXE Shell32.DLL,SHFormatDrive", 1, true |
|
#5
|
|||
|
|||
|
WshShell.Run strCommand [,intWindowStyle] [,bWaitOnReturn]
The Run method creates a new process and runs the command specified by strCommand. The optional parameter intWindowStyle is used to set the window style of the program being run. If the optional parameter bWaitOnReturn is set to True (default is False), then Run will return the return value returned by strCommand. Otherwise it returns 0. Also, if bWaitOnReturn is set to True, then the script will suspend its execution until strCommand finishes. The following table shows the available settings for intWindowStyle. intWindowsStyle Settings 0 Hides the window and activates another window. 1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. 2 Activates the window and displays it as a minimized window. 3 Activates the window and displays it as a maximized window. 4 Displays a window in its most recent size and position. The active window remains active. 5 Activates the window and displays it in its current size and position. 6 Minimizes the specified window and activates the next top-level window in the Z order. 7 Displays the window as a minimized window. The active window remains active. 8 Displays the window in its current state. The active window remains active. 9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. 10 Sets the show state based on the state of the program that started the application. The following VBScript code starts Notepad using the script's own full path name as the parameter for Notepad. Code: Set WshShell = WScript.CreateObject("WScript.Shell") intReturn = WshShell.Run("notepad " & WScript.ScriptFullName, 1, TRUE) WshShell.Popup "Notepad is now closed." http://www.devguru.com/Technologies...hshell_Run.html |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Formatting floppy using VBScript on Win XP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|