36539
Goto Top

VBS-Script Ändern auf automatische systemroot-Erkennung

Hallo

ich hatte mal eine *.VBS gefunden mit dem ich für meine Batch bei Bedarf eine Verknüpfung auf dem Desktop erstellen kann.

set wshshell = CreateObject("WScript.Shell")   
'Ort des Windowsdesktops  
'desktopdir = "System-LW\winnt\profiles\USERID\desktop"  
desktopdir = wshshell.SpecialFolders(0)

neuerlink = desktopdir & "\PC Neustart.lnk"  
set link = wshshell.Createshortcut(neuerlink)
link.TargetPath = "C:\WIN-Scripte\PC-Shutdown-Reboot\PC Neustart.exe"  
link.Save

neuerlink1 = desktopdir & "\PC Ausschalten.lnk"  
set link1 = wshshell.Createshortcut(neuerlink1)
link1.TargetPath = "C:\WIN-Scripte\PC-Shutdown-Reboot\PC Ausschalten.exe"  
link1.Save

'MsgBox ("Verknüpfungen zu "PC Neustart.exe" und "PC Ausschalten.exe" wurden auf dem Desktop angelegt!")  

Könnt ich mir den Code so ändern das in der Zeile 8 und 13 ("link1.TargetPath = -...) das System-LW automatisch vom *.vbs eingestellt wird.

Danke
onegase59

Content-ID: 102579

Url: https://administrator.de/forum/vbs-script-aendern-auf-automatische-systemroot-erkennung-102579.html

Ausgedruckt am: 22.04.2025 um 00:04 Uhr

dog
dog 25.11.2008 um 01:22:41 Uhr
Goto Top
Eine Möglichkeit:
strSystemDrive = wshshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")   
Das benutzt die %SYSTEMDRIVE%-Umgebungsvariable (nicht getestet)

Grüße

Max
36539
36539 25.11.2008 um 01:33:05 Uhr
Goto Top
Danke Max,

Und wie muss ich
strSystemDrive = wshshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")   
in meinen Code einbauen?

so? link1.TargetPath = "strSystemDrive\WIN-Scripte\PC-Shutdown-Reboot\PC Ausschalten.exe"

onegasee59
dog
dog 25.11.2008 um 01:47:08 Uhr
Goto Top
etwa so:

'Wsh Shell Objekt  
set wshshell = CreateObject("WScript.Shell")   
'Ort des Windowsdesktops  
desktopdir = wshshell.SpecialFolders(0)
'Laufwerksbuchstabe  
systemDrive = wshshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")   

neuerlink = desktopdir & "\PC Neustart.lnk"  
set link = wshshell.Createshortcut(neuerlink)
link.TargetPath = systemDrive & "\WIN-Scripte\PC-Shutdown-Reboot\PC Neustart.exe"  
link.Save

neuerlink1 = desktopdir & "\PC Ausschalten.lnk"  
set link1 = wshshell.Createshortcut(neuerlink1)
link1.TargetPath = systemDrive & "\WIN-Scripte\PC-Shutdown-Reboot\PC Ausschalten.exe"  
link1.Save
36539
36539 25.11.2008 um 22:37:43 Uhr
Goto Top
Hallo

Zitat von @dog:
----
etwa so:....

Genau so geht es. face-smile

Herzlichen Dank für Deine Hilfe.

Gruß
onegasee59