Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 16th, 2003, 01:39 PM
Potuncle Potuncle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Eugene, Oregon
Posts: 2 Potuncle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 17th, 2003, 12:37 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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\".

Reply With Quote
  #3  
Old September 17th, 2003, 02:20 PM
Potuncle Potuncle is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Eugene, Oregon
Posts: 2 Potuncle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old September 17th, 2003, 02:49 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,717 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 40 m 34 sec
Reputation Power: 688
You have some extra parentheses, try this

Set wshshell = WScript.CreateObject ("WScript.shell")
wshshell.Run "C:\WINDOWS\RUNDLL32.EXE Shell32.DLL,SHFormatDrive", 1, true

Reply With Quote
  #5  
Old September 18th, 2003, 02:45 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Formatting floppy using VBScript on Win XP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway