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-Key: 102579

Url: https://administrator.de/contentid/102579

Printed on: April 23, 2024 at 19:04 o'clock

Member: dog
dog Nov 25, 2008 at 00:22:41 (UTC)
Goto Top
Eine Möglichkeit:
strSystemDrive = wshshell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")   
Das benutzt die %SYSTEMDRIVE%-Umgebungsvariable (nicht getestet)

Grüße

Max
Mitglied: 36539
36539 Nov 25, 2008 at 00:33:05 (UTC)
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
Member: dog
dog Nov 25, 2008 at 00:47:08 (UTC)
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
Mitglied: 36539
36539 Nov 25, 2008 at 21:37:43 (UTC)
Goto Top
Hallo

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

Genau so geht es. face-smile

Herzlichen Dank für Deine Hilfe.

Gruß
onegasee59