Jump to content

Net use and Windows Vista


Recommended Posts

Hi,

I made a little script, to mount and dismount a network share as a drive in Windows.

When I use the script with Windows XP SP#1 it works fine.

When I use the scirpt with Windows Vista SP#1 it doe not work.

NET USE can be use on Windows XP and Vista, why does the script not work?

Here is the code:

#RequireAdmin
#include <GuiConstants.au3>
#include <Process.au3>


; GUI - Breite und Höhe des Fensters
GuiCreate("Mount Tool", 300, 350)
GuiSetIcon(@ScriptDir & "\logo.ico", 0)

; Schrift
GUISetFont (10, 400, 0, 0)  
GUICtrlCreateLabel ("Tool zum Mounten und Trennen von Laufwerken", 10, 20)

$TextBreite = 380
$label1 = 60

; Checkboxen
GUISetFont (10, 400, 4, 0)  
;GUICtrlCreateLabel ("Explorer", 10, $label1)
$CheckBox1 = GUICtrlCreateCheckbox ("xxx\Software als Laufwerk Z mounten", 20, $label1+15, $TextBreite, 20)
$CheckBox2 = GUICtrlCreateCheckbox ("xxx\Software als Laufwerk Y mounten", 20, $label1+55, $TextBreite, 20)

$ButtonMount = GuiCtrlCreateButton("&Mounten", 40, 250, 80, 30)
GUICtrlSetTip(-1, "Laufwerk mounten")
$ButtonTrennen = GuiCtrlCreateButton("&Trennen", 150, 250, 80, 30)
GUICtrlSetTip(-1, "Laufwerk trennen")
$ButtonExit = GuiCtrlCreateButton("&Ende", 100, 290, 80, 30)
GUICtrlSetTip(-1, "Programm beenden")

; Show the GUI
GuiSetState ()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE Or $msg = $ButtonExit
        Exit

        Case $msg = $GUI_EVENT_MINIMIZE
            MsgBox(0,"", "Dialog minimized",2)
        
        Case $msg = $GUI_EVENT_MAXIMIZE
            MsgBox(0,"", "Dialog restored",2)
        
        Case $msg = $ButtonMount
            MounteLaufwerk()
            
        Case $msg = $ButtonTrennen
            TrenneLaufwerk()    
            
    EndSelect
WEnd

GUIDelete()

Func MounteLaufwerk()
    
    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
        _RunDOS('NET USE Z: \\emi-s2\software /PERSISTENT:NO')
    ;Run("explorer.exe Z:\")
    EndIf

    If GUICtrlRead($CheckBox2) = $GUI_CHECKED Then
        _RunDOS('NET USE Y: \\emi-s2\software /PERSISTENT:NO')
    ;Run("explorer.exe Y:\")
    EndIf

EndFunc


Func TrenneLaufwerk()
    
    If GUICtrlRead($CheckBox1) = $GUI_CHECKED Then
        _RunDOS('NET USE Z: /DELETE')
    EndIf

    If GUICtrlRead($CheckBox2) = $GUI_CHECKED Then
        _RunDOS('NET USE Y: /DELETE')
    EndIf

EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...